@@ -320,7 +320,7 @@ _comp_upvars()
320
320
# interference from user's shell options/settings or environment variables.
321
321
# @param $1 array_name Array name
322
322
# The array name should not start with an underscore "_", which is internally
323
- # used. The array name should not be "GLOBIGNORE".
323
+ # used. The array name should not be "GLOBIGNORE" or "GLOBSORT" .
324
324
# @param $2 pattern Pattern string to be evaluated.
325
325
# This pattern string will be evaluated using "eval", so brace expansions,
326
326
# parameter expansions, command substitutions, and other expansions will be
@@ -335,7 +335,7 @@ _comp_expand_glob()
335
335
printf ' bash-completion: %s: unexpected number of arguments\n' " $FUNCNAME " >&2
336
336
printf ' usage: %s ARRAY_NAME PATTERN\n' " $FUNCNAME " >&2
337
337
return 2
338
- elif [[ $1 == @ (GLOBIGNORE| _* | * [^_a-zA-Z0-9]* | [0-9]* | ' ' ) ]]; then
338
+ elif [[ $1 == @ (GLOBIGNORE| GLOBSORT | _* | * [^_a-zA-Z0-9]* | [0-9]* | ' ' ) ]]; then
339
339
printf ' bash-completion: %s: invalid array name "%s"\n' " $FUNCNAME " " $1 " >&2
340
340
return 2
341
341
fi
@@ -346,8 +346,9 @@ _comp_expand_glob()
346
346
shopt -s nullglob
347
347
shopt -u failglob dotglob
348
348
349
- # Also the user's GLOBIGNORE may affect the result of pathname expansions.
350
- local GLOBIGNORE=
349
+ # Also the user's GLOBIGNORE and GLOBSORT (bash >= 5.3) may affect the
350
+ # result of pathname expansions.
351
+ local GLOBIGNORE=" " GLOBSORT=name
351
352
352
353
eval -- " $1 =()" # a fallback in case that the next line fails.
353
354
eval -- " $1 =($2 )"
0 commit comments