Skip to content

Commit 0fda821

Browse files
committed
fix(_comp_expand_glob): work around GLOBSORT in Bash 5.3
1 parent 8304d33 commit 0fda821

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

bash_completion

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ _comp_upvars()
320320
# interference from user's shell options/settings or environment variables.
321321
# @param $1 array_name Array name
322322
# 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".
324324
# @param $2 pattern Pattern string to be evaluated.
325325
# This pattern string will be evaluated using "eval", so brace expansions,
326326
# parameter expansions, command substitutions, and other expansions will be
@@ -335,7 +335,7 @@ _comp_expand_glob()
335335
printf 'bash-completion: %s: unexpected number of arguments\n' "$FUNCNAME" >&2
336336
printf 'usage: %s ARRAY_NAME PATTERN\n' "$FUNCNAME" >&2
337337
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
339339
printf 'bash-completion: %s: invalid array name "%s"\n' "$FUNCNAME" "$1" >&2
340340
return 2
341341
fi
@@ -346,8 +346,9 @@ _comp_expand_glob()
346346
shopt -s nullglob
347347
shopt -u failglob dotglob
348348

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
351352

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

0 commit comments

Comments
 (0)