Skip to content

Commit

Permalink
Silence 'make checkbashisms'
Browse files Browse the repository at this point in the history
Commit d2bce6d 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 openzfs#10755
  • Loading branch information
behlendorf authored Aug 20, 2020
1 parent 7bba1d4 commit 64025fa
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 20 deletions.
7 changes: 7 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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;}" "{}"' \;); \
Expand Down
17 changes: 8 additions & 9 deletions cmd/vdev_id/vdev_id
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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")
Expand Down Expand Up @@ -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}'`
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion contrib/dracut/90zfs/export-zfs.sh.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

. /lib/dracut-zfs-lib.sh

Expand Down
2 changes: 1 addition & 1 deletion contrib/dracut/90zfs/mount-zfs.sh.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

. /lib/dracut-zfs-lib.sh

Expand Down
2 changes: 1 addition & 1 deletion contrib/dracut/90zfs/parse-zfs.sh.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

. /lib/dracut-lib.sh

Expand Down
2 changes: 1 addition & 1 deletion contrib/dracut/90zfs/zfs-lib.sh.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

command -v getarg >/dev/null || . /lib/dracut-lib.sh
command -v getargbool >/dev/null || {
Expand Down
2 changes: 1 addition & 1 deletion contrib/dracut/90zfs/zfs-load-key.sh.in
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion contrib/dracut/90zfs/zfs-needshutdown.sh.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh

Expand Down
4 changes: 2 additions & 2 deletions contrib/initramfs/zfsunlock
Original file line number Diff line number Diff line change
Expand Up @@ -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..."
Expand All @@ -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."
Expand Down
2 changes: 1 addition & 1 deletion scripts/dkms.mkconf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions scripts/dkms.postbuild
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 64025fa

Please sign in to comment.