Fix SC2181 ("[ $?") outside tests/
Reviewed-by: John Kennedy <john.kennedy@delphix.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes #12042
This commit is contained in:
parent
1d106ab57a
commit
2ca77988a5
@ -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}>&-"
|
||||
|
@ -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])
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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)"
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user