Skip to content

Commit 503cf7b

Browse files
committed
fix(_variables): protect from failglob
1 parent 17c1fab commit 503cf7b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

bash_completion

+4-1
Original file line numberDiff line numberDiff line change
@@ -679,9 +679,12 @@ _variables()
679679
return 0
680680
elif [[ $cur =~ ^(\$\{[#!]?)([A-Za-z0-9_]*)\[([^]]*)$ ]]; then
681681
# Complete ${array[i with ${array[idx]}
682-
local IFS=$'\n'
682+
local reset=$(shopt -po noglob) IFS=$'\n'
683+
set -o noglob
683684
COMPREPLY+=($(compgen -W '$(printf %s\\n "${!'${BASH_REMATCH[2]}'[@]}")' \
684685
-P "${BASH_REMATCH[1]}${BASH_REMATCH[2]}[" -S ']}' -- "${BASH_REMATCH[3]}"))
686+
IFS=$' \t\n'
687+
$reset
685688
# Complete ${arr[@ and ${arr[*
686689
if [[ ${BASH_REMATCH[3]} == [@*] ]]; then
687690
COMPREPLY+=("${BASH_REMATCH[1]}${BASH_REMATCH[2]}[${BASH_REMATCH[3]}]}")

0 commit comments

Comments
 (0)