mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 20:33:08 +00:00
b7db397f61
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).
16 lines
723 B
Fish
16 lines
723 B
Fish
function __fish_is_zfs_feature_enabled -a feature target -d "Returns 0 if the given ZFS feature is available or enabled for the given full-path target (zpool or dataset), or any target if none given"
|
|
set -l pool (string replace -r '/.*' '' -- $target)
|
|
set -l feature_name ""
|
|
if test -z "$pool"
|
|
set feature_name (zpool get -H all | string match -r "\s$feature\s")
|
|
else
|
|
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
|
|
end
|
|
echo $feature_name | read -l _ _ state _
|
|
set -l state (echo $feature_name | cut -f3)
|
|
string match -qr '(active|enabled)' -- $state
|
|
return $status
|
|
end
|