Fix zfs completions under FreeBSD

Under FreeBSD, as annoying as it is, switches must directly follow the
command or subcommand in question, and cannot come after actual payload
argument. Calling `zpool get all -H` instead of `zpool get -H all`
caused error messages to be spewed to the console under FreeBSD when
simply completing `zfs <TAB>`, this should fix that. The change should
also be compatible with other operating systems (namely Linux) that
don't have this requirement, as they (generally) allow arguments to come
before _or_ after the primary non-switch argument (though I do not have
access to a zfs-enabled Linux machine to test this).
This commit is contained in:
Mahmoud Al-Qudsi 2018-05-26 12:20:04 -05:00
parent 46bd0e66b6
commit b7db397f61

View file

@ -2,9 +2,9 @@ function __fish_is_zfs_feature_enabled -a feature target -d "Returns 0 if the gi
set -l pool (string replace -r '/.*' '' -- $target)
set -l feature_name ""
if test -z "$pool"
set feature_name (zpool get all -H | string match -r "\s$feature\s")
set feature_name (zpool get -H all | string match -r "\s$feature\s")
else
set feature_name (zpool get all -H $pool | string match -r "$pool\s$feature\s")
set feature_name (zpool get -H all $pool | string match -r "$pool\s$feature\s")
end
if test $status -ne 0 # No such feature
return 1