From c4aa03a1fdabe22b96bd35bdc93771766eab9cdd Mon Sep 17 00:00:00 2001 From: Nahor Date: Sun, 8 Mar 2026 12:09:31 -0700 Subject: [PATCH] complete: fix completion of commands starting with `-` When trying to complete a command starting with `-`, and more specifically when trying to get the description of possible commands, the dash was interpreted as an option for `__fish_describe_command`, resulting in an "unknown option" most of the time. This is a regression introduced when adding option parsing to `__fish_describe_command` Fixes 7fc27e9e5 (cygwin: improve handling of `.exe` file extension, 2025-11-22) Fixes #12510 Closes #12522 --- src/complete.rs | 7 +++++-- tests/checks/complete.fish | 9 +++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/complete.rs b/src/complete.rs index 2ffa8c461..d8f67867c 100644 --- a/src/complete.rs +++ b/src/complete.rs @@ -999,11 +999,14 @@ fn complete_cmd_desc(&mut self, s: &wstr) { // systems with a large set of manuals, but it should be ok since apropos is only called once. // For Cygwin, also try to find the exact match for the non-exe name let lookup_cmd = sprintf!( - "functions -q __fish_describe_command &&{ __fish_describe_command %s %s}", + "functions -q __fish_describe_command &&{ __fish_describe_command -- %s %s}", &escape(cmd), &no_exe .map(|(cmd_sans_exe, _)| { - sprintf!("; __fish_describe_command --exact %s", escape(cmd_sans_exe)) + sprintf!( + "; __fish_describe_command --exact -- %s", + escape(cmd_sans_exe) + ) }) .unwrap_or_default()[..] ); diff --git a/tests/checks/complete.fish b/tests/checks/complete.fish index 61b4cddeb..b88c0bccd 100644 --- a/tests/checks/complete.fish +++ b/tests/checks/complete.fish @@ -691,3 +691,12 @@ complete command-line-aware-completions -xa "(commandline --cursor; commandline complete -C"command-line-aware-completions " # CHECK: 31 # CHECK: command-line-aware-completions + +begin + : >"$TMPDIR/-command-starting-with-dash" + chmod +x "$TMPDIR/-command-starting-with-dash" + + set -l PATH "$TMPDIR" $PATH + complete -C"-command-starting-with" + # CHECK: -command-starting-with-dash{{\t}}command +end