Skip to content

Commit ce98f68

Browse files
committed
fix(_comp_expand_glob): set LC_COLLATE for the sorting order
In sourcing the file `000_bash_completion_compat.bash` located in /etc/bash_completion.d, we rely on the sorting order of the pathname expansions. However, this can be broken by locales that collates digits after the alphabets. We set LC_COLLATE to C and unset LC_ALL (which might override LC_COLLATE) while keeping LC_CTYPE.
1 parent 0fda821 commit ce98f68

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

bash_completion

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,10 @@ _comp_expand_glob()
350350
# result of pathname expansions.
351351
local GLOBIGNORE="" GLOBSORT=name
352352

353+
# To canonicalize the sorting order of the generated paths, we set
354+
# LC_COLLATE=C and unset LC_ALL while preserving LC_CTYPE.
355+
local LC_COLLATE=C LC_CTYPE=${LC_ALL:-${LC_CTYPE:-${LANG-}}} LC_ALL=
356+
353357
eval -- "$1=()" # a fallback in case that the next line fails.
354358
eval -- "$1=($2)"
355359

0 commit comments

Comments
 (0)