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:
szubersk
2022-11-12 22:22:49 +10:00
committed by Brian Behlendorf
parent c3b6fd3d59
commit a5087965fe
10 changed files with 95 additions and 94 deletions
@@ -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 -3
View File
@@ -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