From 57bd21e7ce20c7fd79a398b1842cb2c3b7b27416 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Sun, 10 Sep 2023 18:11:23 +0200 Subject: [PATCH] __fish_complete_command: Fix --foo= logic This was already supposed to handle `--foo=bar` cases, except it printed the `--foo=` again, causing fish to take that as part of the token. See #9538 for a similar thing with __fish_complete_directories. Fixes #10011 (cherry picked from commit b03327f5d2e0c7062f5af13d194e5c989df28c69) --- share/functions/__fish_complete_command.fish | 2 +- tests/checks/complete.fish | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/share/functions/__fish_complete_command.fish b/share/functions/__fish_complete_command.fish index ddbfb0273..875d72d23 100644 --- a/share/functions/__fish_complete_command.fish +++ b/share/functions/__fish_complete_command.fish @@ -3,7 +3,7 @@ function __fish_complete_command --description 'Complete using all available com switch $ctoken case '*=*' set ctoken (string split "=" -- $ctoken) - printf '%s\n' $ctoken[1]=(complete -C "$ctoken[2]") + complete -C "$ctoken[2]" case '-*' # do not try to complete options as commands return case '*' diff --git a/tests/checks/complete.fish b/tests/checks/complete.fish index 1d40c84c7..79ef35f4c 100644 --- a/tests/checks/complete.fish +++ b/tests/checks/complete.fish @@ -532,3 +532,7 @@ begin end rm -r $tmpdir + +complete -C'complete --command=fish' | head -n 1 | string replace -rf '\t.*' '' +# (one "--command=" is okay, we used to get "--command=--command=" +# CHECK: --command=fish