mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-12-13 09:24:03 +08:00
85504ca694
This is an additional tool, and this function is executed on source time so we'd spew errors. (also remove an ineffective line - it's probably *nicer* with the read, but that's not what's currently effectively doing anything)
18 lines
734 B
Fish
18 lines
734 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"
|
|
type -q zpool
|
|
or return
|
|
set -l pool (string replace -r '/.*' '' -- $target)
|
|
set -l feature_name ""
|
|
if test -z "$pool"
|
|
set feature_name (zpool get -H all 2>/dev/null | string match -r "\s$feature\s")
|
|
else
|
|
set feature_name (zpool get -H all $pool 2>/dev/null | string match -r "$pool\s$feature\s")
|
|
end
|
|
if test $status -ne 0 # No such feature
|
|
return 1
|
|
end
|
|
set -l state (echo $feature_name | cut -f3)
|
|
string match -qr '(active|enabled)' -- $state
|
|
return $status
|
|
end
|