allow subcommand_path to match even with flags

With the old version flags between subcommands
weren't allowed (as it was doing exact match).
This solution is still not perfect (as it uses '.+')
and could potentially swallow other subcommands.
This commit is contained in:
Tim Reddehase 2018-09-26 09:42:30 +02:00 committed by David Gillies
parent 4f3e5f496b
commit 5f46ad3b9b
No known key found for this signature in database
GPG key ID: BD350530941BDC96

View file

@ -35,9 +35,10 @@ function __fish_%s_no_subcommand --description 'Test if %s has yet to be given t
return 0 return 0
end end
function __fish_%s_seen_subcommand_path --description 'Test whether the full path of subcommands is the current path' function __fish_%s_seen_subcommand_path --description 'Test whether the full path of subcommands is the current path'
set -l cmd (commandline -opc) set -l cmd (commandline -opc)
set -e cmd[1] set -e cmd[1]
return (test (string trim -- "$argv") = (string trim -- "$cmd")) set -l pattern (string replace -a " " ".+" "$argv")
string match -r "$pattern" (string trim -- "$cmd")
end end
# borrowed from current fish-shell master, since it is not in current 2.7.1 release # borrowed from current fish-shell master, since it is not in current 2.7.1 release
function __fish_seen_argument function __fish_seen_argument