aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmd/zed/zed.d/zed-functions.sh8
-rw-r--r--config/ax_python_devel.m43
-rwxr-xr-xcontrib/dracut/02zfsexpandknowledge/module-setup.sh.in3
-rwxr-xr-xcontrib/dracut/90zfs/mount-zfs.sh.in6
-rwxr-xr-xcontrib/dracut/90zfs/zfs-lib.sh.in6
-rwxr-xr-xetc/init.d/zfs-zed.in22
-rw-r--r--etc/zfs/zfs-functions.in12
-rwxr-xr-xscripts/commitcheck.sh4
-rwxr-xr-xscripts/zfs.sh4
-rwxr-xr-xscripts/zimport.sh6
-rwxr-xr-xscripts/zloop.sh7
11 files changed, 29 insertions, 52 deletions
diff --git a/cmd/zed/zed.d/zed-functions.sh b/cmd/zed/zed.d/zed-functions.sh
index 1fd388862..e809241de 100644
--- a/cmd/zed/zed.d/zed-functions.sh
+++ b/cmd/zed/zed.d/zed-functions.sh
@@ -127,9 +127,7 @@ zed_lock()
# Obtain a lock on the file bound to the given file descriptor.
#
eval "exec ${fd}> '${lockfile}'"
- err="$(flock --exclusive "${fd}" 2>&1)"
- # shellcheck disable=SC2181
- if [ $? -ne 0 ]; then
+ if ! err="$(flock --exclusive "${fd}" 2>&1)"; then
zed_log_err "failed to lock \"${lockfile}\": ${err}"
fi
@@ -165,9 +163,7 @@ zed_unlock()
fi
# Release the lock and close the file descriptor.
- err="$(flock --unlock "${fd}" 2>&1)"
- # shellcheck disable=SC2181
- if [ $? -ne 0 ]; then
+ if ! err="$(flock --unlock "${fd}" 2>&1)"; then
zed_log_err "failed to unlock \"${lockfile}\": ${err}"
fi
eval "exec ${fd}>&-"
diff --git a/config/ax_python_devel.m4 b/config/ax_python_devel.m4
index c51b45b7d..faf6c2b0d 100644
--- a/config/ax_python_devel.m4
+++ b/config/ax_python_devel.m4
@@ -148,8 +148,7 @@ variable to configure. See ``configure --help'' for reference.
# Check if you have distutils, else fail
#
AC_MSG_CHECKING([for the distutils Python package])
- ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`
- if test $? -eq 0; then
+ if ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
diff --git a/contrib/dracut/02zfsexpandknowledge/module-setup.sh.in b/contrib/dracut/02zfsexpandknowledge/module-setup.sh.in
index f4b7b8cdc..12f5d91e9 100755
--- a/contrib/dracut/02zfsexpandknowledge/module-setup.sh.in
+++ b/contrib/dracut/02zfsexpandknowledge/module-setup.sh.in
@@ -17,8 +17,7 @@ get_pool_devices() {
local prefix
local resolved
poolconfigtemp=`mktemp`
- @sbindir@/zpool list -v -H -P "$1" > "$poolconfigtemp" 2>&1
- if [ "$?" != "0" ] ; then
+ if ! @sbindir@/zpool list -v -H -P "$1" > "$poolconfigtemp" 2>&1 ; then
poolconfigoutput=$(cat "$poolconfigtemp")
dinfo "zfsexpandknowledge: pool $1 cannot be listed: $poolconfigoutput"
else
diff --git a/contrib/dracut/90zfs/mount-zfs.sh.in b/contrib/dracut/90zfs/mount-zfs.sh.in
index 4a892e938..5ad6a0f26 100755
--- a/contrib/dracut/90zfs/mount-zfs.sh.in
+++ b/contrib/dracut/90zfs/mount-zfs.sh.in
@@ -38,11 +38,9 @@ modprobe zfs 2>/dev/null
udevadm settle
if [ "${root}" = "zfs:AUTO" ] ; then
- ZFS_DATASET="$(find_bootfs)"
- if [ $? -ne 0 ] ; then
+ if ! ZFS_DATASET="$(find_bootfs)" ; then
zpool import -N -a ${ZPOOL_IMPORT_OPTS}
- ZFS_DATASET="$(find_bootfs)"
- if [ $? -ne 0 ] ; then
+ if ! ZFS_DATASET="$(find_bootfs)" ; then
warn "ZFS: No bootfs attribute found in importable pools."
export_all -F
diff --git a/contrib/dracut/90zfs/zfs-lib.sh.in b/contrib/dracut/90zfs/zfs-lib.sh.in
index f3cdd1503..98e4452a7 100755
--- a/contrib/dracut/90zfs/zfs-lib.sh.in
+++ b/contrib/dracut/90zfs/zfs-lib.sh.in
@@ -5,12 +5,8 @@ command -v getargbool >/dev/null || {
# Compatibility with older Dracut versions.
# With apologies to the Dracut developers.
getargbool() {
- if ! [ -z "$_b" ]; then
- unset _b
- fi
_default="$1"; shift
- _b=$(getarg "$@")
- [ $? -ne 0 ] && [ -z "$_b" ] && _b="$_default"
+ ! _b=$(getarg "$@") && [ -z "$_b" ] && _b="$_default"
if [ -n "$_b" ]; then
[ "$_b" = "0" ] && return 1
[ "$_b" = "no" ] && return 1
diff --git a/etc/init.d/zfs-zed.in b/etc/init.d/zfs-zed.in
index 6af9ee60c..8890a7122 100755
--- a/etc/init.d/zfs-zed.in
+++ b/etc/init.d/zfs-zed.in
@@ -61,20 +61,16 @@ do_stop()
check_module_loaded "zfs" || exit 0
zfs_action "Stopping ZFS Event Daemon" zfs_daemon_stop \
- "$ZED_PIDFILE" "$ZED" "$ZED_NAME"
- if [ "$?" -eq "0" ]
+ "$ZED_PIDFILE" "$ZED" "$ZED_NAME" || return "$?"
+
+ # Let's see if we have any pools imported
+ pools=$("$ZPOOL" list -H -oname)
+ if [ -z "$pools" ]
then
- # Let's see if we have any pools imported
- pools=$("$ZPOOL" list -H -oname)
- if [ -z "$pools" ]
- then
- # No pools imported, it is/should be safe/possible to
- # unload modules.
- zfs_action "Unloading modules" rmmod zfs zunicode \
- zavl zcommon znvpair zlua spl
- return "$?"
- fi
- else
+ # No pools imported, it is/should be safe/possible to
+ # unload modules.
+ zfs_action "Unloading modules" rmmod zfs zunicode \
+ zavl zcommon znvpair zlua spl
return "$?"
fi
}
diff --git a/etc/zfs/zfs-functions.in b/etc/zfs/zfs-functions.in
index 54f2ebc0e..dbe131732 100644
--- a/etc/zfs/zfs-functions.in
+++ b/etc/zfs/zfs-functions.in
@@ -182,15 +182,17 @@ zfs_daemon_stop()
# LSB functions
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \
--pidfile "$PIDFILE" --name "$DAEMON_NAME"
- [ "$?" = 0 ] && rm -f "$PIDFILE"
+ ret="$?"
+ [ "$ret" = 0 ] && rm -f "$PIDFILE"
- return $?
+ return "$ret"
elif type killproc > /dev/null 2>&1 ; then
# Fedora/RedHat functions
killproc -p "$PIDFILE" "$DAEMON_NAME"
- [ "$?" = 0 ] && rm -f "$PIDFILE"
+ ret="$?"
+ [ "$ret" = 0 ] && rm -f "$PIDFILE"
- return $?
+ return "$ret"
else
# Unsupported
return 3
@@ -371,7 +373,7 @@ in_mtab()
local mntpnt="$1"
# Remove 'unwanted' characters.
mntpnt=$(printf '%b\n' "$mntpnt" | sed -e 's,/,,g' \
- -e 's,-,,g' -e 's,\.,,g' -e 's, ,,g')
+ -e 's,-,,g' -e 's,\.,,g' -e 's, ,,g')
local var
var="$(eval echo MTAB_$mntpnt)"
diff --git a/scripts/commitcheck.sh b/scripts/commitcheck.sh
index 71cf52166..0077eb6b0 100755
--- a/scripts/commitcheck.sh
+++ b/scripts/commitcheck.sh
@@ -87,9 +87,7 @@ coverity_fix_commit()
IFS='
'
for line in $(git log -n 1 --pretty=%b "$REF" | grep -E '^CID'); do
- echo "$line" | grep -E '^CID [[:digit:]]+: ([[:graph:]]+|[[:space:]])+ \(([[:upper:]]|\_)+\)' > /dev/null
- # shellcheck disable=SC2181
- if [ $? -ne 0 ]; then
+ if ! echo "$line" | grep -qE '^CID [[:digit:]]+: ([[:graph:]]+|[[:space:]])+ \(([[:upper:]]|\_)+\)'; then
echo "error: commit message has an improperly formatted CID defect line"
error=1
fi
diff --git a/scripts/zfs.sh b/scripts/zfs.sh
index 2f5f3f8fd..39c49d71e 100755
--- a/scripts/zfs.sh
+++ b/scripts/zfs.sh
@@ -120,9 +120,7 @@ load_module_linux() {
echo "Loading: $FILE ($VERSION)"
fi
- $LDMOD "$KMOD" >/dev/null 2>&1
- # shellcheck disable=SC2181
- if [ $? -ne 0 ]; then
+ if ! $LDMOD "$KMOD" >/dev/null 2>&1; then
echo "Failed to load $KMOD"
return 1
fi
diff --git a/scripts/zimport.sh b/scripts/zimport.sh
index 6c3b415ff..0490f785d 100755
--- a/scripts/zimport.sh
+++ b/scripts/zimport.sh
@@ -491,10 +491,8 @@ for TAG in $POOL_TAGS; do
POOL_NAME=$($ZPOOL_CMD import -d "$POOL_DIR_COPY" | \
awk '/pool:/ { print $2; exit 0 }')
- $ZPOOL_CMD import -N -d "$POOL_DIR_COPY" \
- "$POOL_NAME" &>/dev/null
- # shellcheck disable=SC2181
- if [ $? -ne 0 ]; then
+ if ! $ZPOOL_CMD import -N -d "$POOL_DIR_COPY"
+ "$POOL_NAME" &>/dev/null; then
fail_nonewline
ERROR=1
else
diff --git a/scripts/zloop.sh b/scripts/zloop.sh
index bbe326aa0..f2eff6e94 100755
--- a/scripts/zloop.sh
+++ b/scripts/zloop.sh
@@ -62,11 +62,8 @@ function usage
function or_die
{
# shellcheck disable=SC2068
- $@
- # shellcheck disable=SC2181
- if [[ $? -ne 0 ]]; then
- # shellcheck disable=SC2145
- echo "Command failed: $@"
+ if ! $@; then
+ echo "Command failed: $*"
exit 1
fi
}