You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Line 10:](javascript:setPosition(10, 3))
[ "$?" == 0 ] || echo "no"
^-- [SC2181](https://www.shellcheck.net/wiki/SC2181) (style): Check exit code directly with e.g. 'if mycmd;', not indirectly with $?.
Here's what I wanted or expected to see:
No warning or no misleading warning, and an exception on the SC2181 page.
Rationale: The warnings suggests ("Check exit code directly with e.g. 'if mycmd;'") to write code like this:
#!/bin/bashfuncname()
{
false
}
set -e
if funcname;thenecho yes
elseecho no
fi
This code passes, but is dangerous: errexit is now inactive in funcname and all errors in funcname or functions called by it will silently ignore errexit. So, after a function, doing something like rval=$? and then testing $rval seems the most clean to me (before funcname calls return, you need to set errexit off, and after catching rval, you need to turn it on again).
The text was updated successfully, but these errors were encountered:
For bugs
Here's a snippet or screenshot that shows the problem:
Here's what shellcheck currently says:
Here's what I wanted or expected to see:
No warning or no misleading warning, and an exception on the SC2181 page.
Rationale: The warnings suggests ("Check exit code directly with e.g. 'if mycmd;'") to write code like this:
This code passes, but is dangerous: errexit is now inactive in
funcname
and all errors infuncname
or functions called by it will silently ignore errexit. So, after a function, doing something likerval=$?
and then testing$rval
seems the most clean to me (beforefuncname
callsreturn
, you need to set errexit off, and after catchingrval
, you need to turn it on again).The text was updated successfully, but these errors were encountered: