mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-23 19:04:45 +03:00
Ubuntu 22.04 integration: ShellCheck
- Add new SC2312 global exclude. ``` Consider invoking this command separately to avoid masking its return value (or use '|| true' to ignore). [SC2312] ``` - Correct errors detected by new ShellCheck version. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu> Reviewed-by: George Melikov <mail@gmelikov.ru> Signed-off-by: szubersk <szuberskidamian@gmail.com> Closes #14148
This commit is contained in:
committed by
Brian Behlendorf
parent
c3b6fd3d59
commit
a5087965fe
@@ -63,11 +63,11 @@ __zfs_list_filesystems()
|
||||
__zfs_match_snapshot()
|
||||
{
|
||||
local base_dataset="${cur%@*}"
|
||||
if [ "$base_dataset" != "$cur" ]
|
||||
if [[ "$base_dataset" != "$cur" ]]
|
||||
then
|
||||
$__ZFS_CMD list -H -o name -s name -t snapshot -d 1 "$base_dataset"
|
||||
else
|
||||
if [ "$cur" != "" ] && __zfs_list_datasets "$cur" &> /dev/null
|
||||
if [[ "$cur" != "" ]] && __zfs_list_datasets "$cur" &> /dev/null
|
||||
then
|
||||
$__ZFS_CMD list -H -o name -s name -t filesystem,volume -r "$cur" | tail -n +2
|
||||
# We output the base dataset name even though we might be
|
||||
@@ -104,7 +104,7 @@ __zfs_match_snapshot()
|
||||
__zfs_match_snapshot_or_bookmark()
|
||||
{
|
||||
local base_dataset="${cur%[#@]*}"
|
||||
if [ "$base_dataset" != "$cur" ]
|
||||
if [[ "$base_dataset" != "$cur" ]]
|
||||
then
|
||||
if [[ $cur == *@* ]]
|
||||
then
|
||||
@@ -114,7 +114,7 @@ __zfs_match_snapshot_or_bookmark()
|
||||
fi
|
||||
else
|
||||
$__ZFS_CMD list -H -o name -s name -t filesystem,volume
|
||||
if [ -e "$cur" ] && $__ZFS_CMD list -H -o name -s name -t filesystem,volume "$cur" &> /dev/null
|
||||
if [[ -e "$cur" ]] && $__ZFS_CMD list -H -o name -s name -t filesystem,volume "$cur" &> /dev/null
|
||||
then
|
||||
echo "$cur@"
|
||||
echo "$cur#"
|
||||
@@ -126,10 +126,10 @@ __zfs_match_multiple_snapshots()
|
||||
{
|
||||
local existing_opts
|
||||
existing_opts="$(expr "$cur" : '\(.*\)[%,]')"
|
||||
if [ -e "$existing_opts" ]
|
||||
if [[ -e "$existing_opts" ]]
|
||||
then
|
||||
local base_dataset="${cur%@*}"
|
||||
if [ "$base_dataset" != "$cur" ]
|
||||
if [[ "$base_dataset" != "$cur" ]]
|
||||
then
|
||||
local cur="${cur##*,}"
|
||||
if [[ $cur =~ ^%|%.*% ]]
|
||||
@@ -199,7 +199,7 @@ __zfs_complete_multiple_options()
|
||||
|
||||
mapfile -t COMPREPLY < <(compgen -W "$options" -- "${cur##*,}")
|
||||
existing_opts=$(expr "$cur" : '\(.*,\)')
|
||||
if [ -n "$existing_opts" ]
|
||||
if [[ -n "$existing_opts" ]]
|
||||
then
|
||||
COMPREPLY=( "${COMPREPLY[@]/#/${existing_opts}}" )
|
||||
fi
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
get_devtype() {
|
||||
local typ
|
||||
typ=$(udevadm info --query=property --name="$1" | sed -n 's|^ID_FS_TYPE=||p')
|
||||
if [ -z "$typ" ] ; then
|
||||
if [[ -z "$typ" ]] ; then
|
||||
typ=$(blkid -c /dev/null "$1" -o value -s TYPE)
|
||||
fi
|
||||
echo "$typ"
|
||||
@@ -22,7 +22,7 @@ get_pool_devices() {
|
||||
else
|
||||
awk -F '\t' '/\t\/dev/ { print $2 }' "$poolconfigtemp" | \
|
||||
while read -r pooldev ; do
|
||||
if [ -e "$pooldev" ] ; then
|
||||
if [[ -e "$pooldev" ]] ; then
|
||||
resolved="$(readlink -f "$pooldev")"
|
||||
dinfo "zfsexpandknowledge: pool $1 has device $pooldev (which resolves to $resolved)"
|
||||
echo "$resolved"
|
||||
@@ -38,15 +38,15 @@ find_zfs_block_devices() {
|
||||
local fstype
|
||||
local _
|
||||
numfields="$(awk '{print NF; exit}' /proc/self/mountinfo)"
|
||||
if [ "$numfields" = "10" ] ; then
|
||||
if [[ "$numfields" = "10" ]] ; then
|
||||
fields="_ _ _ _ mp _ _ fstype dev _"
|
||||
else
|
||||
fields="_ _ _ _ mp _ _ _ fstype dev _"
|
||||
fi
|
||||
# shellcheck disable=SC2086
|
||||
while read -r ${fields?} ; do
|
||||
[ "$fstype" = "zfs" ] || continue
|
||||
[ "$mp" = "$1" ] && get_pool_devices "${dev%%/*}"
|
||||
[[ "$fstype" = "zfs" ]] || continue
|
||||
[[ "$mp" = "$1" ]] && get_pool_devices "${dev%%/*}"
|
||||
done < /proc/self/mountinfo
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ check() {
|
||||
local _depdevtype
|
||||
|
||||
# shellcheck disable=SC2154
|
||||
if [ -n "$hostonly" ]; then
|
||||
if [[ -n "$hostonly" ]]; then
|
||||
|
||||
for mp in \
|
||||
"/" \
|
||||
@@ -92,7 +92,7 @@ if [ -n "$hostonly" ]; then
|
||||
mp=$(readlink -f "$mp")
|
||||
mountpoint "$mp" >/dev/null 2>&1 || continue
|
||||
blockdevs=$(find_zfs_block_devices "$mp")
|
||||
if [ -z "$blockdevs" ] ; then continue ; fi
|
||||
if [[ -z "$blockdevs" ]] ; then continue ; fi
|
||||
dinfo "zfsexpandknowledge: block devices backing ZFS dataset $mp: ${blockdevs//$'\n'/ }"
|
||||
for dev in $blockdevs
|
||||
do
|
||||
@@ -100,9 +100,9 @@ if [ -n "$hostonly" ]; then
|
||||
fstype=$(get_devtype "$dev")
|
||||
host_fs_types["$dev"]="$fstype"
|
||||
majmin=$(get_maj_min "$dev")
|
||||
if [ -d "/sys/dev/block/$majmin/slaves" ] ; then
|
||||
if [[ -d "/sys/dev/block/$majmin/slaves" ]] ; then
|
||||
for _depdev in "/sys/dev/block/$majmin/slaves"/*; do
|
||||
[ -f "$_depdev/dev" ] || continue
|
||||
[[ -f "$_depdev/dev" ]] || continue
|
||||
_depdev="/dev/${_depdev##*/}"
|
||||
_depdevname=$(udevadm info --query=property --name="$_depdev" | sed -n 's|^DEVNAME=||p')
|
||||
_depdevtype=$(get_devtype "$_depdevname")
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
check() {
|
||||
# We depend on udev-rules being loaded
|
||||
[ "${1}" = "-d" ] && return 0
|
||||
[[ "${1}" = "-d" ]] && return 0
|
||||
|
||||
# Verify the zfs tool chain
|
||||
for tool in "zgenhostid" "zpool" "zfs" "mount.zfs"; do
|
||||
@@ -50,7 +50,7 @@ install() {
|
||||
fi
|
||||
|
||||
inst_hook cmdline 95 "${moddir}/parse-zfs.sh"
|
||||
if [ -n "${systemdutildir}" ]; then
|
||||
if [[ -n "${systemdutildir}" ]]; then
|
||||
inst_script "${moddir}/zfs-generator.sh" "${systemdutildir}/system-generators/dracut-zfs-generator"
|
||||
fi
|
||||
inst_hook pre-mount 90 "${moddir}/zfs-load-key.sh"
|
||||
@@ -68,7 +68,7 @@ install() {
|
||||
|
||||
# Synchronize initramfs and system hostid
|
||||
if ! inst_simple -H @sysconfdir@/hostid; then
|
||||
if HOSTID="$(hostid 2>/dev/null)" && [ "${HOSTID}" != "00000000" ]; then
|
||||
if HOSTID="$(hostid 2>/dev/null)" && [[ "${HOSTID}" != "00000000" ]]; then
|
||||
zgenhostid -o "${initdir}@sysconfdir@/hostid" "${HOSTID}"
|
||||
mark_hostonly @sysconfdir@/hostid
|
||||
fi
|
||||
|
||||
@@ -640,8 +640,8 @@ setup_snapshot_booting()
|
||||
# rpool/ROOT/debian/boot@snap2 => rpool/ROOT/debian_snap2/boot
|
||||
# rpool/ROOT/debian/usr@snap2 => rpool/ROOT/debian_snap2/usr
|
||||
# rpool/ROOT/debian/var@snap2 => rpool/ROOT/debian_snap2/var
|
||||
subfs="${s##$rootfs}"
|
||||
subfs="${subfs%%@$snapname}"
|
||||
subfs="${s##"$rootfs"}"
|
||||
subfs="${subfs%%@"$snapname"}"
|
||||
|
||||
destfs="${rootfs}_${snapname}" # base fs.
|
||||
[ -n "$subfs" ] && destfs="${destfs}$subfs" # + sub fs.
|
||||
|
||||
Reference in New Issue
Block a user