summaryrefslogtreecommitdiffstats
path: root/contrib/bash_completion.d/zfs.in
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/bash_completion.d/zfs.in')
-rw-r--r--contrib/bash_completion.d/zfs.in23
1 files changed, 14 insertions, 9 deletions
diff --git a/contrib/bash_completion.d/zfs.in b/contrib/bash_completion.d/zfs.in
index f650c8f50..41ce2f871 100644
--- a/contrib/bash_completion.d/zfs.in
+++ b/contrib/bash_completion.d/zfs.in
@@ -139,6 +139,7 @@ __zfs_match_multiple_snapshots()
fi
local range_start
range_start="$(expr "$cur" : '\(.*%\)')"
+ # shellcheck disable=SC2016
$__ZFS_CMD list -H -o name -s name -t snapshot -d 1 "$base_dataset" | sed 's$.*@$'"$range_start"'$g'
fi
else
@@ -163,7 +164,7 @@ __zfs_argument_chosen()
then
return 0
fi
- for property in $@
+ for property in "$@"
do
if [[ $prev == "$property"* ]]
then
@@ -181,6 +182,7 @@ __zfs_complete_ordered_arguments()
local list2=$2
local cur=$3
local extra=$4
+ # shellcheck disable=SC2086
if __zfs_argument_chosen $list1
then
COMPREPLY=($(compgen -W "$list2 $extra" -- "$cur"))
@@ -193,9 +195,10 @@ __zfs_complete_multiple_options()
{
local options=$1
local cur=$2
+ local existing_opts
COMPREPLY=($(compgen -W "$options" -- "${cur##*,}"))
- local existing_opts=$(expr "$cur" : '\(.*,\)')
+ existing_opts=$(expr "$cur" : '\(.*,\)')
if [[ $existing_opts ]]
then
COMPREPLY=( "${COMPREPLY[@]/#/${existing_opts}}" )
@@ -290,6 +293,7 @@ __zfs_complete()
*)
if ! __zfs_complete_switch "H,r,p,d,o,t,s"
then
+ # shellcheck disable=SC2046
if __zfs_argument_chosen $(__zfs_get_properties)
then
COMPREPLY=($(compgen -W "$(__zfs_match_snapshot)" -- "$cur"))
@@ -303,7 +307,7 @@ __zfs_complete()
inherit)
if ! __zfs_complete_switch "r"
then
- __zfs_complete_ordered_arguments "$(__zfs_get_inheritable_properties)" "$(__zfs_match_snapshot)" $cur
+ __zfs_complete_ordered_arguments "$(__zfs_get_inheritable_properties)" "$(__zfs_match_snapshot)" "$cur"
fi
;;
list)
@@ -369,7 +373,7 @@ __zfs_complete()
esac
;;
set)
- __zfs_complete_ordered_arguments "$(__zfs_get_editable_properties)" "$(__zfs_match_snapshot)" $cur
+ __zfs_complete_ordered_arguments "$(__zfs_get_editable_properties)" "$(__zfs_match_snapshot)" "$cur"
__zfs_complete_nospace
;;
upgrade)
@@ -388,7 +392,7 @@ __zfs_complete()
destroy)
if ! __zfs_complete_switch "d,f,n,p,R,r,v"
then
- __zfs_complete_multiple_options "$(__zfs_match_multiple_snapshots)" $cur
+ __zfs_complete_multiple_options "$(__zfs_match_multiple_snapshots)" "$cur"
__zfs_complete_nospace
fi
;;
@@ -425,7 +429,7 @@ __zpool_list_pools()
__zpool_complete()
{
- local cur prev cmd cmds
+ local cur prev cmd cmds pools
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
@@ -440,7 +444,7 @@ __zpool_complete()
case "${cmd}" in
get)
- __zfs_complete_ordered_arguments "$(__zpool_get_properties)" "$(__zpool_list_pools)" $cur
+ __zfs_complete_ordered_arguments "$(__zpool_get_properties)" "$(__zpool_list_pools)" "$cur"
return 0
;;
import)
@@ -453,12 +457,13 @@ __zpool_complete()
return 0
;;
set)
- __zfs_complete_ordered_arguments "$(__zpool_get_editable_properties)" "$(__zpool_list_pools)" $cur
+ __zfs_complete_ordered_arguments "$(__zpool_get_editable_properties)" "$(__zpool_list_pools)" "$cur"
__zfs_complete_nospace
return 0
;;
add|attach|clear|create|detach|offline|online|remove|replace)
- local pools="$(__zpool_list_pools)"
+ pools="$(__zpool_list_pools)"
+ # shellcheck disable=SC2086
if __zfs_argument_chosen $pools
then
_filedir