From 0a2443e3eec8557273dd905df9a28dc177861023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Mon, 19 Jun 2023 10:44:10 +0300 Subject: [PATCH] fix(__load_completion): quoted compspec for variants (#1008) * fix(__load_completion): quoted compspec for variants Closes https://github.com/scop/bash-completion/issues/995 Co-authored-by: Koichi Murase --- bash_completion | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/bash_completion b/bash_completion index b0cc2051b93..48e32dbba7c 100644 --- a/bash_completion +++ b/bash_completion @@ -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