Fix env completions

Our old friend, local variable inside a block.

Also account for the fact that the current token is often empty.

Fixes #8881
This commit is contained in:
Fabian Homborg 2022-04-16 08:36:58 +02:00
parent 2fa51f1843
commit eb468ea744

View File

@ -1,14 +1,16 @@
set -l is_gnu
if env --version &>/dev/null
set -l is_gnu --is-gnu
set is_gnu --is-gnu
end
function __fish_env_remaining_args -V is_gnu
set -l argv (commandline -opc) (commandline -ct)
if set -q is_gnu[1]
argparse -s i/ignore-environment u/unset= help version -- (commandline -opc) (commandline -ct) 2>/dev/null
or return 1
argparse -s i/ignore-environment u/unset= help version -- $argv 2>/dev/null
or return 0
else
argparse -s 0 i P= S= u= v -- (commandline -opc) (commandline -ct) 2>/dev/null
or return 1
argparse -s 0 i P= S= u= v -- $argv 2>/dev/null
or return 0
end
# argv[1] is `env` or an alias.
@ -27,7 +29,7 @@ function __fish_env_remaining_args -V is_gnu
string join \n -- $argv
# Return true if there is a subcommand.
set -q argv[1]
test -n "$argv[1]"
end
function __fish_complete_env_subcommand