completions: fix double evaluation of tokenized commandline

Fix cases like

    eval my-cmd (commandline -o)
    complete -C "my-cmd $(commandline -o)"

In both cases, we spuriously evaluate tokens like "(inside-quoted-string)"
as command substitutions. Fix this by escaping the strings.  The momentarily
regresses the intended purpose of "eval" -- to expand variables -- but the
next commit will fix that.
This commit is contained in:
Johannes Altmanninger
2024-01-06 08:45:33 +01:00
parent 368017905e
commit 798527d79a
10 changed files with 14 additions and 16 deletions

View File

@@ -18,7 +18,7 @@ function __fish_complete_subcommand -d "Complete subcommand" --no-scope-shadowin
set -l options_with_param $argv
if not string length -q -- $subcommand
set -l cmd (commandline -cop) (commandline -ct)
set -l cmd (commandline -cop | string escape) (commandline -ct)
while set -q cmd[1]
set -l token $cmd[1]
set -e cmd[1]