From ce98f686c0aac19bc5b0938cbfa245a2f06d8b79 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Mon, 10 Jun 2024 12:58:30 +0900 Subject: [PATCH] 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. --- bash_completion | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bash_completion b/bash_completion index b7b4a96bb13..ad466da9457 100644 --- a/bash_completion +++ b/bash_completion @@ -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)"