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 <insane.prawny@gmail.com>
Reviewed-by:  Gabriel A. Devenyi <gdevenyi@gmail.com>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes 
This commit is contained in:
Brian Behlendorf 2020-08-20 13:45:47 -07:00 committed by GitHub
parent 7bba1d404c
commit 64025fa3a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 26 additions and 20 deletions

View File

@ -145,6 +145,13 @@ checkbashisms:
-o -name 'build' -prune \ -o -name 'build' -prune \
-o -name 'tests' -prune \ -o -name 'tests' -prune \
-o -name 'config' -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*' \ -o -type f ! -name 'config*' \
! -name 'libtool' \ ! -name 'libtool' \
-exec bash -c 'awk "NR==1 && /\#\!.*bin\/sh.*/ {print FILENAME;}" "{}"' \;); \ -exec bash -c 'awk "NR==1 && /\#\!.*bin\/sh.*/ {print FILENAME;}" "{}"' \;); \

View File

@ -114,9 +114,8 @@ EOF
} }
map_slot() { map_slot() {
local LINUX_SLOT=$1 LINUX_SLOT=$1
local CHANNEL=$2 CHANNEL=$2
local MAPPED_SLOT=
MAPPED_SLOT=`awk "\\$1 == \"slot\" && \\$2 == ${LINUX_SLOT} && \ MAPPED_SLOT=`awk "\\$1 == \"slot\" && \\$2 == ${LINUX_SLOT} && \
\\$4 ~ /^${CHANNEL}$|^$/ { print \\$3; exit }" $CONFIG` \\$4 ~ /^${CHANNEL}$|^$/ { print \\$3; exit }" $CONFIG`
@ -127,9 +126,9 @@ map_slot() {
} }
map_channel() { map_channel() {
local MAPPED_CHAN= MAPPED_CHAN=
local PCI_ID=$1 PCI_ID=$1
local PORT=$2 PORT=$2
case $TOPOLOGY in case $TOPOLOGY in
"sas_switch") "sas_switch")
@ -487,7 +486,7 @@ alias_handler () {
# digits as partitions, causing alias creation to fail. This # digits as partitions, causing alias creation to fail. This
# ambiguity seems unavoidable, so devices using this facility # ambiguity seems unavoidable, so devices using this facility
# must not use such names. # must not use such names.
local DM_PART= DM_PART=
if echo $DM_NAME | grep -q -E 'p[0-9][0-9]*$' ; then if echo $DM_NAME | grep -q -E 'p[0-9][0-9]*$' ; then
if [ "$DEVTYPE" != "partition" ] ; then if [ "$DEVTYPE" != "partition" ] ; then
DM_PART=`echo $DM_NAME | awk -Fp '/p/{print "-part"$2}'` DM_PART=`echo $DM_NAME | awk -Fp '/p/{print "-part"$2}'`
@ -549,7 +548,7 @@ if [ ! -r $CONFIG ] ; then
exit 0 exit 0
fi fi
if [ -z "$DEV" -a -z "$ENCLOSURE_MODE" ] ; then if [ -z "$DEV" ] && [ -z "$ENCLOSURE_MODE" ] ; then
echo "Error: missing required option -d" echo "Error: missing required option -d"
exit 1 exit 1
fi fi
@ -565,7 +564,7 @@ fi
TOPOLOGY=${TOPOLOGY:-sas_direct} TOPOLOGY=${TOPOLOGY:-sas_direct}
# Should we create /dev/by-enclosure symlinks? # 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) ID_ENCLOSURE=$(enclosure_handler)
if [ -z "$ID_ENCLOSURE" ] ; then if [ -z "$ID_ENCLOSURE" ] ; then
exit 0 exit 0

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
. /lib/dracut-zfs-lib.sh . /lib/dracut-zfs-lib.sh

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
. /lib/dracut-zfs-lib.sh . /lib/dracut-zfs-lib.sh

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
. /lib/dracut-lib.sh . /lib/dracut-lib.sh

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
command -v getarg >/dev/null || . /lib/dracut-lib.sh command -v getarg >/dev/null || . /lib/dracut-lib.sh
command -v getargbool >/dev/null || { command -v getargbool >/dev/null || {

View File

@ -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 # only run this on systemd systems, we handle the decrypt in mount-zfs.sh in the mount hook otherwise
[ -e /bin/systemctl ] || return 0 [ -e /bin/systemctl ] || return 0

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh

View File

@ -8,7 +8,7 @@ while [ ! -e /run/zfs_fs_name ]; do
if [ -e /run/zfs_unlock_complete ]; then if [ -e /run/zfs_unlock_complete ]; then
exit 0 exit 0
fi fi
sleep 0.5 sleep 1
done done
echo echo
echo "Unlocking encrypted ZFS filesystems..." echo "Unlocking encrypted ZFS filesystems..."
@ -31,7 +31,7 @@ while [ ! -e /run/zfs_unlock_complete ]; do
fi fi
# Wait for another filesystem to unlock. # Wait for another filesystem to unlock.
while [ "$(cat /run/zfs_fs_name)" = "$zfs_fs_name" ] && [ ! -e /run/zfs_unlock_complete ]; do while [ "$(cat /run/zfs_fs_name)" = "$zfs_fs_name" ] && [ ! -e /run/zfs_unlock_complete ]; do
sleep 0.5 sleep 1
done done
else else
echo "Wrong password. Try again." echo "Wrong password. Try again."

View File

@ -13,7 +13,7 @@ while getopts "n:v:c:f:" opt; do
esac esac
done 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>" echo "Usage: $PROG -n <pkgname> -v <pkgver> -c <pkgcfg> -f <filename>"
exit 1 exit 1
fi fi

View File

@ -12,8 +12,8 @@ while getopts "a:k:n:t:v:" opt; do
esac esac
done done
if [ -z "${arch}" -o -z "${kver}" -o -z "${pkgname}" -o \ if [ -z "${arch}" ] || [ -z "${kver}" ] || [ -z "${pkgname}" ] || \
-z "${tree}" -o -z "${pkgver}" ]; then [ -z "${tree}" ] || [ -z "${pkgver}" ]; then
echo "Usage: $PROG -a <arch> -k <kver> -n <pkgname>" \ echo "Usage: $PROG -a <arch> -k <kver> -n <pkgname>" \
"-t <tree> -v <pkgver>" "-t <tree> -v <pkgver>"
exit 1 exit 1