aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2020-08-20 13:45:47 -0700
committerGitHub <[email protected]>2020-08-20 13:45:47 -0700
commit64025fa3a1f0f710f7f8678f2ac459b07ed9f88f (patch)
tree740ffc937bb1c9e4964054ad619f464cc060fe0c
parent7bba1d404cd213223cfca017035f9ebf8683a8ef (diff)
Silence 'make checkbashisms'
Commit d2bce6d03 added the 'make checkbashisms' target but did not resolve all of the bashisms in the scripts. This commit doesn't resolve them all either but it does fix up a few, and it excludes the others so 'make checkstyle' no longer prints warnings. It's a small step in the right direction. * Dracut is Linux specific and itself depends on bash. Therefore all dracut support scripts can be bash specific, update their shebang accordingly. * zed-functions.sh, zfs-import, zfs-mount, zfs-zed, smart paxcheck.sh, make_gitrev.sh - these scripts were excuded from the check until they can be updated and properly tested. * zfsunlock - only whole values for sleep are allowed. * vdev_id - removed unneeded locals; use && instead of -a. * dkms.mkconf, dkms.postbuil - use || instead of -o. Reviewed-by: InsanePrawn <[email protected]> Reviewed-by: Gabriel A. Devenyi <[email protected]> Reviewed-by: Ryan Moeller <[email protected]> Reviewed-by: George Melikov <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #10755
-rw-r--r--Makefile.am7
-rwxr-xr-xcmd/vdev_id/vdev_id17
-rwxr-xr-xcontrib/dracut/90zfs/export-zfs.sh.in2
-rwxr-xr-xcontrib/dracut/90zfs/mount-zfs.sh.in2
-rwxr-xr-xcontrib/dracut/90zfs/parse-zfs.sh.in2
-rwxr-xr-xcontrib/dracut/90zfs/zfs-lib.sh.in2
-rwxr-xr-xcontrib/dracut/90zfs/zfs-load-key.sh.in2
-rwxr-xr-xcontrib/dracut/90zfs/zfs-needshutdown.sh.in2
-rwxr-xr-xcontrib/initramfs/zfsunlock4
-rwxr-xr-xscripts/dkms.mkconf2
-rwxr-xr-xscripts/dkms.postbuild4
11 files changed, 26 insertions, 20 deletions
diff --git a/Makefile.am b/Makefile.am
index 840604c23..b409d2196 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -145,6 +145,13 @@ checkbashisms:
-o -name 'build' -prune \
-o -name 'tests' -prune \
-o -name 'config' -prune \
+ -o -name 'zed-functions.sh*' -prune \
+ -o -name 'zfs-import*' -prune \
+ -o -name 'zfs-mount*' -prune \
+ -o -name 'zfs-zed*' -prune \
+ -o -name 'smart' -prune \
+ -o -name 'paxcheck.sh' -prune \
+ -o -name 'make_gitrev.sh' -prune \
-o -type f ! -name 'config*' \
! -name 'libtool' \
-exec bash -c 'awk "NR==1 && /\#\!.*bin\/sh.*/ {print FILENAME;}" "{}"' \;); \
diff --git a/cmd/vdev_id/vdev_id b/cmd/vdev_id/vdev_id
index a79aed3b5..8a75e638b 100755
--- a/cmd/vdev_id/vdev_id
+++ b/cmd/vdev_id/vdev_id
@@ -114,9 +114,8 @@ EOF
}
map_slot() {
- local LINUX_SLOT=$1
- local CHANNEL=$2
- local MAPPED_SLOT=
+ LINUX_SLOT=$1
+ CHANNEL=$2
MAPPED_SLOT=`awk "\\$1 == \"slot\" && \\$2 == ${LINUX_SLOT} && \
\\$4 ~ /^${CHANNEL}$|^$/ { print \\$3; exit }" $CONFIG`
@@ -127,9 +126,9 @@ map_slot() {
}
map_channel() {
- local MAPPED_CHAN=
- local PCI_ID=$1
- local PORT=$2
+ MAPPED_CHAN=
+ PCI_ID=$1
+ PORT=$2
case $TOPOLOGY in
"sas_switch")
@@ -487,7 +486,7 @@ alias_handler () {
# digits as partitions, causing alias creation to fail. This
# ambiguity seems unavoidable, so devices using this facility
# must not use such names.
- local DM_PART=
+ DM_PART=
if echo $DM_NAME | grep -q -E 'p[0-9][0-9]*$' ; then
if [ "$DEVTYPE" != "partition" ] ; then
DM_PART=`echo $DM_NAME | awk -Fp '/p/{print "-part"$2}'`
@@ -549,7 +548,7 @@ if [ ! -r $CONFIG ] ; then
exit 0
fi
-if [ -z "$DEV" -a -z "$ENCLOSURE_MODE" ] ; then
+if [ -z "$DEV" ] && [ -z "$ENCLOSURE_MODE" ] ; then
echo "Error: missing required option -d"
exit 1
fi
@@ -565,7 +564,7 @@ fi
TOPOLOGY=${TOPOLOGY:-sas_direct}
# Should we create /dev/by-enclosure symlinks?
-if [ "$ENCLOSURE_MODE" = "yes" -a "$TOPOLOGY" = "sas_direct" ] ; then
+if [ "$ENCLOSURE_MODE" = "yes" ] && [ "$TOPOLOGY" = "sas_direct" ] ; then
ID_ENCLOSURE=$(enclosure_handler)
if [ -z "$ID_ENCLOSURE" ] ; then
exit 0
diff --git a/contrib/dracut/90zfs/export-zfs.sh.in b/contrib/dracut/90zfs/export-zfs.sh.in
index 892650383..09e4a3cc0 100755
--- a/contrib/dracut/90zfs/export-zfs.sh.in
+++ b/contrib/dracut/90zfs/export-zfs.sh.in
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
. /lib/dracut-zfs-lib.sh
diff --git a/contrib/dracut/90zfs/mount-zfs.sh.in b/contrib/dracut/90zfs/mount-zfs.sh.in
index 73300a9b6..f5b3d9056 100755
--- a/contrib/dracut/90zfs/mount-zfs.sh.in
+++ b/contrib/dracut/90zfs/mount-zfs.sh.in
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
. /lib/dracut-zfs-lib.sh
diff --git a/contrib/dracut/90zfs/parse-zfs.sh.in b/contrib/dracut/90zfs/parse-zfs.sh.in
index eccfdc6bc..6a805ae24 100755
--- a/contrib/dracut/90zfs/parse-zfs.sh.in
+++ b/contrib/dracut/90zfs/parse-zfs.sh.in
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
. /lib/dracut-lib.sh
diff --git a/contrib/dracut/90zfs/zfs-lib.sh.in b/contrib/dracut/90zfs/zfs-lib.sh.in
index 44021c6e5..f470bfcc5 100755
--- a/contrib/dracut/90zfs/zfs-lib.sh.in
+++ b/contrib/dracut/90zfs/zfs-lib.sh.in
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
command -v getarg >/dev/null || . /lib/dracut-lib.sh
command -v getargbool >/dev/null || {
diff --git a/contrib/dracut/90zfs/zfs-load-key.sh.in b/contrib/dracut/90zfs/zfs-load-key.sh.in
index 85e55c51b..ff586ef65 100755
--- a/contrib/dracut/90zfs/zfs-load-key.sh.in
+++ b/contrib/dracut/90zfs/zfs-load-key.sh.in
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
# only run this on systemd systems, we handle the decrypt in mount-zfs.sh in the mount hook otherwise
[ -e /bin/systemctl ] || return 0
diff --git a/contrib/dracut/90zfs/zfs-needshutdown.sh.in b/contrib/dracut/90zfs/zfs-needshutdown.sh.in
index e3d1b59cc..ddd3edae0 100755
--- a/contrib/dracut/90zfs/zfs-needshutdown.sh.in
+++ b/contrib/dracut/90zfs/zfs-needshutdown.sh.in
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
diff --git a/contrib/initramfs/zfsunlock b/contrib/initramfs/zfsunlock
index f6b6b9dbe..cf8e45249 100755
--- a/contrib/initramfs/zfsunlock
+++ b/contrib/initramfs/zfsunlock
@@ -8,7 +8,7 @@ while [ ! -e /run/zfs_fs_name ]; do
if [ -e /run/zfs_unlock_complete ]; then
exit 0
fi
- sleep 0.5
+ sleep 1
done
echo
echo "Unlocking encrypted ZFS filesystems..."
@@ -31,7 +31,7 @@ while [ ! -e /run/zfs_unlock_complete ]; do
fi
# Wait for another filesystem to unlock.
while [ "$(cat /run/zfs_fs_name)" = "$zfs_fs_name" ] && [ ! -e /run/zfs_unlock_complete ]; do
- sleep 0.5
+ sleep 1
done
else
echo "Wrong password. Try again."
diff --git a/scripts/dkms.mkconf b/scripts/dkms.mkconf
index 8c5555973..28d9609f7 100755
--- a/scripts/dkms.mkconf
+++ b/scripts/dkms.mkconf
@@ -13,7 +13,7 @@ while getopts "n:v:c:f:" opt; do
esac
done
-if [ -z "${pkgname}" -o -z "${pkgver}" -o -z "${filename}" ]; then
+if [ -z "${pkgname}" ] || [ -z "${pkgver}" ] || [ -z "${filename}" ]; then
echo "Usage: $PROG -n <pkgname> -v <pkgver> -c <pkgcfg> -f <filename>"
exit 1
fi
diff --git a/scripts/dkms.postbuild b/scripts/dkms.postbuild
index 299c02d6e..81de47587 100755
--- a/scripts/dkms.postbuild
+++ b/scripts/dkms.postbuild
@@ -12,8 +12,8 @@ while getopts "a:k:n:t:v:" opt; do
esac
done
-if [ -z "${arch}" -o -z "${kver}" -o -z "${pkgname}" -o \
- -z "${tree}" -o -z "${pkgver}" ]; then
+if [ -z "${arch}" ] || [ -z "${kver}" ] || [ -z "${pkgname}" ] || \
+ [ -z "${tree}" ] || [ -z "${pkgver}" ]; then
echo "Usage: $PROG -a <arch> -k <kver> -n <pkgname>" \
"-t <tree> -v <pkgver>"
exit 1