Skip to content

Commit

Permalink
fix(_comp_expand_glob): set LC_COLLATE for the sorting order
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
akinomyoga committed Jun 10, 2024
1 parent 0fda821 commit ce98f68
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bash_completion
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@ _comp_expand_glob()
# result of pathname expansions.
local GLOBIGNORE="" GLOBSORT=name

# To canonicalize the sorting order of the generated paths, we set
# LC_COLLATE=C and unset LC_ALL while preserving LC_CTYPE.
local LC_COLLATE=C LC_CTYPE=${LC_ALL:-${LC_CTYPE:-${LANG-}}} LC_ALL=

eval -- "$1=()" # a fallback in case that the next line fails.
eval -- "$1=($2)"

Expand Down

0 comments on commit ce98f68

Please sign in to comment.