File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -416,7 +416,7 @@ _comp_split()
416
416
# completions.
417
417
_comp_compgen ()
418
418
{
419
- local _append=" " _var=COMPREPLY _cur=${cur-} IFS =$' \t\n '
419
+ local _append=" " _var=COMPREPLY _cur=${cur-} _ifs =$' \t\n '
420
420
local -a _split_options=(-l)
421
421
422
422
local OPTIND=1 OPTARG=" " OPTERR=0 _opt
@@ -430,8 +430,8 @@ _comp_compgen()
430
430
fi
431
431
_var=$OPTARG
432
432
;;
433
- l) IFS =$' \n ' ;;
434
- F) IFS =$OPTARG ;;
433
+ l) _ifs =$' \n ' ;;
434
+ F) _ifs =$OPTARG ;;
435
435
c) _cur=$OPTARG ;;
436
436
R) _cur=" " ;;
437
437
* )
@@ -445,7 +445,14 @@ _comp_compgen()
445
445
printf ' bash_completion: %s: unexpected number of arguments.\n' " $FUNCNAME " >&2
446
446
printf ' usage: %s [-alR|-F SEP|-v ARR|-c CUR] -- ARGS...' " $FUNCNAME " >&2
447
447
return 2
448
- elif [[ $* == * \$ [0-9]* || $* == * \$\{ [0-9]* ]]; then
448
+ elif
449
+ # Note: $* in the below checks would be affected by uncontrolled IFS in
450
+ # bash >= 5.0, so we need to set IFS to the normal value. The behavior
451
+ # in bash < 5.0, where unquoted $* in conditional command did not honor
452
+ # IFS, was a bug.
453
+ local IFS=$' \t\n '
454
+ [[ $* == * \$ [0-9]* || $* == * \$\{ [0-9]* ]]
455
+ then
449
456
# Note: extglob *\$?(\{)[0-9]* can be extremely slow when the string
450
457
# "${*:2:_nopt}" becomes longer, so we test \$[0-9] and \$\{[0-9]
451
458
# separately.
@@ -454,7 +461,10 @@ _comp_compgen()
454
461
fi
455
462
456
463
local _result
457
- _result=$( compgen " $@ " ${_cur: +-- " $_cur " } ) || {
464
+ _result=$(
465
+ IFS=$_ifs
466
+ compgen " $@ " ${_cur: +-- " $_cur " }
467
+ ) || {
458
468
local _status=$?
459
469
if [[ $_append ]]; then
460
470
# make sure existence of variable
You can’t perform that action at this time.
0 commit comments