mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-23 19:04:45 +03:00
Turn shellcheck into a normal make target. Fix new files it caught
This checks every file it checked (and a few more), but explicitly instead of "if it works it works" best-effort (which wasn't that good anyway) Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes #10512 Closes #12101
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
include $(top_srcdir)/config/Substfiles.am
|
||||
include $(top_srcdir)/config/Shellcheck.am
|
||||
|
||||
bashcompletiondir = $(sysconfdir)/bash_completion.d
|
||||
|
||||
@@ -6,3 +7,7 @@ noinst_DATA = zfs
|
||||
|
||||
EXTRA_DIST += $(noinst_DATA)
|
||||
SUBSTFILES += $(noinst_DATA)
|
||||
|
||||
SHELLCHECKSCRIPTS = $(noinst_DATA)
|
||||
SHELLCHECK_SHELL = bash
|
||||
SHELLCHECK_IGNORE = ,SC2207
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user