test: fix locale-dependent failure in "don't expand file name"#569
Merged
Aloxaf merged 1 commit intoAloxaf:masterfrom Mar 15, 2026
Merged
test: fix locale-dependent failure in "don't expand file name"#569Aloxaf merged 1 commit intoAloxaf:masterfrom
Aloxaf merged 1 commit intoAloxaf:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix locale-dependent test failure in "don't expand file name"
Summary
This PR adds a single line —
export LC_ALL=C— to the test suite(
test/fzftab.ztst) to enforce deterministic sort order. Without it, the"don't expand file name" test fails on machines running a non-C locale (e.g.
en_US.UTF-8) because locale-aware collation sorts filenames differently thanASCII order. No production code is touched.
TL;DR — detailed explanation
The test case "don't expand file name" (line 206 of
test/fzftab.ztst) verifiesthat fzf-tab does not execute shell metacharacters embedded in filenames. It
creates a file named
dir
echo yes > calledpre-sets a sentinel file
calledtono, triggers completion, and then assertscalled:no— proving the backtick expression was never evaluated as a commandsubstitution.
The test fails on non-C locales for an unrelated reason: the expected completion
order is:
All three names share the prefix
dir, so the tiebreaker is the fourthcharacter:
1,2, or a backtick. Under C locale, backtick (\x60, ASCII 96)sorts after digits, so the backtick filename comes last. Under
en_US.UTF-8(and most Unicode-aware locales), backtick sorts before alphanumeric
characters, putting
dir\...`` first and breaking the expected order.This is a purely accidental failure — the test is not about sort order — but it
causes the whole test case to be reported as failed on any developer machine not
running a C locale.
History
LC_ALL=Cto production code(
lib/-ftb-generate-complist), forcing C-locale sort order for all users.locale, not override it.
fixed.
Fix
Add
export LC_ALL=Cto the%prepsection of the test file, immediately afterunset -m LC_\*which already clears all locale variables:This sets C locale for the test shell and is inherited by the
zptysubprocessstarted later by
comptestinit, ensuring deterministic ASCII collation for alltest cases regardless of the developer's system locale.
No production code is touched.
No interference with other tests
All expected outputs in the test file use ASCII characters. C-locale collation
for ASCII strings is identical to any Unicode-aware locale, so no other test is
affected by this change.
The
ZSH_TEST_LANGmechanism (lines 6–14) is unaffected. That code searches fora UTF-8 aware locale by testing
[[ é = ? ]]— in zsh,?is a glob patternmatching exactly one character, so this expression is only true when the locale
correctly treats the two-byte UTF-8 sequence
éas a single character. Thefound locale is stored in
ZSH_TEST_LANGand used exclusively forcharacter-width assertions elsewhere in the test file. It has nothing to do with
sort order.