Skip to content

Commit

Permalink
fix(__load_completion): quoted compspec for variants (#1008)
Browse files Browse the repository at this point in the history
* fix(__load_completion): quoted compspec for variants

Closes #995
Co-authored-by: Koichi Murase <myoga.murase@gmail.com>
  • Loading branch information
scop authored Jun 19, 2023
1 parent 116980e commit 0a2443e
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions bash_completion
Original file line number Diff line number Diff line change
Expand Up @@ -3011,21 +3011,19 @@ __load_completion()
# At least $cmd is expected to have a completion set when
# we return successfully; see if it already does
if compspec=$(complete -p "$cmd" 2>/dev/null); then
local -a extspecs=()
# $cmd is the case in which we do backslash processing
[[ $backslash ]] && extspecs+=("$backslash$cmd")
[[ $backslash ]] && eval "$compspec \"\$backslash\$cmd\""
# If invoked without path, that one should be set, too
# ...but let's not overwrite an existing one, if any
[[ $origcmd != */* ]] &&
! complete -p "$origcmd" &>/dev/null &&
extspecs+=("$origcmd")
((${#extspecs[*]} != 0)) && $compspec "${extspecs[@]}"
eval "$compspec \"\$origcmd\""
return 0
fi
# If not, see if we got one for $cmdname
if [[ $cmdname != "$cmd" ]] && compspec=$(complete -p "$cmdname" 2>/dev/null); then
# Use that for $cmd too, if we have a full path to it
[[ $cmd == /* ]] && $compspec "$cmd"
[[ $cmd == /* ]] && eval "$compspec \"\$cmd\""
return 0
fi
# Nothing expected was set, continue lookup
Expand Down

0 comments on commit 0a2443e

Please sign in to comment.