mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-27 11:29:36 +03:00
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.
|
# Obtain a lock on the file bound to the given file descriptor.
|
||||||
#
|
#
|
||||||
eval "exec ${fd}> '${lockfile}'"
|
eval "exec ${fd}> '${lockfile}'"
|
||||||
err="$(flock --exclusive "${fd}" 2>&1)"
|
if ! err="$(flock --exclusive "${fd}" 2>&1)"; then
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
zed_log_err "failed to lock \"${lockfile}\": ${err}"
|
zed_log_err "failed to lock \"${lockfile}\": ${err}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -165,9 +163,7 @@ zed_unlock()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Release the lock and close the file descriptor.
|
# Release the lock and close the file descriptor.
|
||||||
err="$(flock --unlock "${fd}" 2>&1)"
|
if ! err="$(flock --unlock "${fd}" 2>&1)"; then
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
zed_log_err "failed to unlock \"${lockfile}\": ${err}"
|
zed_log_err "failed to unlock \"${lockfile}\": ${err}"
|
||||||
fi
|
fi
|
||||||
eval "exec ${fd}>&-"
|
eval "exec ${fd}>&-"
|
||||||
|
@ -148,8 +148,7 @@ variable to configure. See ``configure --help'' for reference.
|
|||||||
# Check if you have distutils, else fail
|
# Check if you have distutils, else fail
|
||||||
#
|
#
|
||||||
AC_MSG_CHECKING([for the distutils Python package])
|
AC_MSG_CHECKING([for the distutils Python package])
|
||||||
ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`
|
if ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`; then
|
||||||
if test $? -eq 0; then
|
|
||||||
AC_MSG_RESULT([yes])
|
AC_MSG_RESULT([yes])
|
||||||
else
|
else
|
||||||
AC_MSG_RESULT([no])
|
AC_MSG_RESULT([no])
|
||||||
|
@ -17,8 +17,7 @@ get_pool_devices() {
|
|||||||
local prefix
|
local prefix
|
||||||
local resolved
|
local resolved
|
||||||
poolconfigtemp=`mktemp`
|
poolconfigtemp=`mktemp`
|
||||||
@sbindir@/zpool list -v -H -P "$1" > "$poolconfigtemp" 2>&1
|
if ! @sbindir@/zpool list -v -H -P "$1" > "$poolconfigtemp" 2>&1 ; then
|
||||||
if [ "$?" != "0" ] ; then
|
|
||||||
poolconfigoutput=$(cat "$poolconfigtemp")
|
poolconfigoutput=$(cat "$poolconfigtemp")
|
||||||
dinfo "zfsexpandknowledge: pool $1 cannot be listed: $poolconfigoutput"
|
dinfo "zfsexpandknowledge: pool $1 cannot be listed: $poolconfigoutput"
|
||||||
else
|
else
|
||||||
|
@ -38,11 +38,9 @@ modprobe zfs 2>/dev/null
|
|||||||
udevadm settle
|
udevadm settle
|
||||||
|
|
||||||
if [ "${root}" = "zfs:AUTO" ] ; then
|
if [ "${root}" = "zfs:AUTO" ] ; then
|
||||||
ZFS_DATASET="$(find_bootfs)"
|
if ! ZFS_DATASET="$(find_bootfs)" ; then
|
||||||
if [ $? -ne 0 ] ; then
|
|
||||||
zpool import -N -a ${ZPOOL_IMPORT_OPTS}
|
zpool import -N -a ${ZPOOL_IMPORT_OPTS}
|
||||||
ZFS_DATASET="$(find_bootfs)"
|
if ! ZFS_DATASET="$(find_bootfs)" ; then
|
||||||
if [ $? -ne 0 ] ; then
|
|
||||||
warn "ZFS: No bootfs attribute found in importable pools."
|
warn "ZFS: No bootfs attribute found in importable pools."
|
||||||
export_all -F
|
export_all -F
|
||||||
|
|
||||||
|
@ -5,12 +5,8 @@ command -v getargbool >/dev/null || {
|
|||||||
# Compatibility with older Dracut versions.
|
# Compatibility with older Dracut versions.
|
||||||
# With apologies to the Dracut developers.
|
# With apologies to the Dracut developers.
|
||||||
getargbool() {
|
getargbool() {
|
||||||
if ! [ -z "$_b" ]; then
|
|
||||||
unset _b
|
|
||||||
fi
|
|
||||||
_default="$1"; shift
|
_default="$1"; shift
|
||||||
_b=$(getarg "$@")
|
! _b=$(getarg "$@") && [ -z "$_b" ] && _b="$_default"
|
||||||
[ $? -ne 0 ] && [ -z "$_b" ] && _b="$_default"
|
|
||||||
if [ -n "$_b" ]; then
|
if [ -n "$_b" ]; then
|
||||||
[ "$_b" = "0" ] && return 1
|
[ "$_b" = "0" ] && return 1
|
||||||
[ "$_b" = "no" ] && return 1
|
[ "$_b" = "no" ] && return 1
|
||||||
|
@ -61,20 +61,16 @@ do_stop()
|
|||||||
check_module_loaded "zfs" || exit 0
|
check_module_loaded "zfs" || exit 0
|
||||||
|
|
||||||
zfs_action "Stopping ZFS Event Daemon" zfs_daemon_stop \
|
zfs_action "Stopping ZFS Event Daemon" zfs_daemon_stop \
|
||||||
"$ZED_PIDFILE" "$ZED" "$ZED_NAME"
|
"$ZED_PIDFILE" "$ZED" "$ZED_NAME" || return "$?"
|
||||||
if [ "$?" -eq "0" ]
|
|
||||||
|
# Let's see if we have any pools imported
|
||||||
|
pools=$("$ZPOOL" list -H -oname)
|
||||||
|
if [ -z "$pools" ]
|
||||||
then
|
then
|
||||||
# Let's see if we have any pools imported
|
# No pools imported, it is/should be safe/possible to
|
||||||
pools=$("$ZPOOL" list -H -oname)
|
# unload modules.
|
||||||
if [ -z "$pools" ]
|
zfs_action "Unloading modules" rmmod zfs zunicode \
|
||||||
then
|
zavl zcommon znvpair zlua spl
|
||||||
# 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
|
|
||||||
return "$?"
|
return "$?"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -182,15 +182,17 @@ zfs_daemon_stop()
|
|||||||
# LSB functions
|
# LSB functions
|
||||||
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \
|
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \
|
||||||
--pidfile "$PIDFILE" --name "$DAEMON_NAME"
|
--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
|
elif type killproc > /dev/null 2>&1 ; then
|
||||||
# Fedora/RedHat functions
|
# Fedora/RedHat functions
|
||||||
killproc -p "$PIDFILE" "$DAEMON_NAME"
|
killproc -p "$PIDFILE" "$DAEMON_NAME"
|
||||||
[ "$?" = 0 ] && rm -f "$PIDFILE"
|
ret="$?"
|
||||||
|
[ "$ret" = 0 ] && rm -f "$PIDFILE"
|
||||||
|
|
||||||
return $?
|
return "$ret"
|
||||||
else
|
else
|
||||||
# Unsupported
|
# Unsupported
|
||||||
return 3
|
return 3
|
||||||
|
@ -87,9 +87,7 @@ coverity_fix_commit()
|
|||||||
IFS='
|
IFS='
|
||||||
'
|
'
|
||||||
for line in $(git log -n 1 --pretty=%b "$REF" | grep -E '^CID'); do
|
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
|
if ! echo "$line" | grep -qE '^CID [[:digit:]]+: ([[:graph:]]+|[[:space:]])+ \(([[:upper:]]|\_)+\)'; then
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "error: commit message has an improperly formatted CID defect line"
|
echo "error: commit message has an improperly formatted CID defect line"
|
||||||
error=1
|
error=1
|
||||||
fi
|
fi
|
||||||
|
@ -120,9 +120,7 @@ load_module_linux() {
|
|||||||
echo "Loading: $FILE ($VERSION)"
|
echo "Loading: $FILE ($VERSION)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
$LDMOD "$KMOD" >/dev/null 2>&1
|
if ! $LDMOD "$KMOD" >/dev/null 2>&1; then
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "Failed to load $KMOD"
|
echo "Failed to load $KMOD"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
@ -491,10 +491,8 @@ for TAG in $POOL_TAGS; do
|
|||||||
POOL_NAME=$($ZPOOL_CMD import -d "$POOL_DIR_COPY" | \
|
POOL_NAME=$($ZPOOL_CMD import -d "$POOL_DIR_COPY" | \
|
||||||
awk '/pool:/ { print $2; exit 0 }')
|
awk '/pool:/ { print $2; exit 0 }')
|
||||||
|
|
||||||
$ZPOOL_CMD import -N -d "$POOL_DIR_COPY" \
|
if ! $ZPOOL_CMD import -N -d "$POOL_DIR_COPY"
|
||||||
"$POOL_NAME" &>/dev/null
|
"$POOL_NAME" &>/dev/null; then
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
fail_nonewline
|
fail_nonewline
|
||||||
ERROR=1
|
ERROR=1
|
||||||
else
|
else
|
||||||
|
@ -62,11 +62,8 @@ function usage
|
|||||||
function or_die
|
function or_die
|
||||||
{
|
{
|
||||||
# shellcheck disable=SC2068
|
# shellcheck disable=SC2068
|
||||||
$@
|
if ! $@; then
|
||||||
# shellcheck disable=SC2181
|
echo "Command failed: $*"
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
# shellcheck disable=SC2145
|
|
||||||
echo "Command failed: $@"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user