diff --git a/share/functions/__fish_seen_subcommand_from.fish b/share/functions/__fish_seen_subcommand_from.fish index fe9203cdf..ccf7e05aa 100644 --- a/share/functions/__fish_seen_subcommand_from.fish +++ b/share/functions/__fish_seen_subcommand_from.fish @@ -6,5 +6,5 @@ function __fish_seen_subcommand_from set -l regex (string escape --style=regex -- (commandline -pxc)[2..] | string join '|') - string match -rq -- '^'$regex'$' $argv + string match -rq -- "^$regex"'$' $argv end diff --git a/tests/checks/complete.fish b/tests/checks/complete.fish index 90659c31a..cbdbf7f4d 100644 --- a/tests/checks/complete.fish +++ b/tests/checks/complete.fish @@ -614,3 +614,10 @@ function __fish_describe_command end test (count (complete -C"wh" | string match -rv "\tcommand|^while")) -gt 0 && echo "found" || echo "fail" # CHECK: found + +set -l commands check search show +complete -c testcommand -n "not __fish_seen_subcommand_from $commands" -a 'check\t"Check the frobnicator" search\t"Search for frobs" show\t"Show all frobs"' +complete -C'testcommand ' +# CHECK: check{{\t}}Check the frobnicator +# CHECK: search{{\t}}Search for frobs +# CHECK: show{{\t}}Show all frobs