1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

ctdb-scripts: Ignore shellcheck SC2181 warning (use of $?)

Given the size of the command substitutions it would be less clear to
embed the assignments and substitutions inside a conditional.  It is
clearer if the exit code is checked afterwards.

However, do fix some untidy uses of != instead of -ne when comparing
with $?.  Make the code easier to understand by reversing the logic
and using -eq and ||.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
Martin Schwenke 2017-08-11 12:49:32 +10:00 committed by Amitay Isaacs
parent 2b0e266d07
commit b71becc150
3 changed files with 10 additions and 2 deletions

View File

@ -39,6 +39,8 @@ fi
sed -r -n "s@.*-(.*(${pat}).*),([0-9]*).*@\3 \1@p" |
while read pid name ; do
trace=$(cat "/proc/${pid}/stack" 2>/dev/null)
# No! Checking the exit code afterwards is actually clearer...
# shellcheck disable=SC2181
if [ $? -eq 0 ] ; then
echo "---- Stack trace of interesting process ${pid}[${name}] ----"
echo "$trace"

View File

@ -26,7 +26,9 @@ parse_options ()
{
temp=$(getopt -n "ctdb_diagnostics" -o "n:cwh" -l no-ads,help -- "$@")
[ $? != 0 ] && usage
# No! Checking the exit code afterwards is actually clearer...
# shellcheck disable=SC2181
[ $? -eq 0 ] || usage
eval set -- "$temp"

View File

@ -81,7 +81,9 @@ parse_options ()
# Not on the previous line - local returns 0!
temp=$(POSIXLY_CORRECT=1 getopt -n "$prog" -o "cf:hno:pqvPi" -l help -- "$@")
[ $? != 0 ] && usage
# No! Checking the exit code afterwards is actually clearer...
# shellcheck disable=SC2181
[ $? -eq 0 ] || usage
eval set -- "$temp"
@ -147,6 +149,8 @@ get_nodes_with_status ()
if [ -z "$ctdb_status_output" ] ; then
ctdb_status_output=$(ctdb -X status 2>&1)
# No! Checking the exit code afterwards is actually clearer...
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "${prog}: unable to get status of CTDB nodes" >&2
echo "$ctdb_status_output" >&2