Closed lahemi closed 8 years ago
@lahemi Thanks. If you don't mind, I will first patch the linter we use to detect this anti-pattern, because the best fixes are fixes where you make sure you don't make the same error again ;-)
Sure, that's obviously a better way to approach this : )
See https://github.com/koalaman/shellcheck/issues/726 for the associated ShellCheck issue. Turns out that this is much trickier than expected.
cmd; if [ $? -eq 0 ]
andcmd; if [ $? -ne 0 ]
are redundant, as you are checking the return value of[
.if
expects a command, meaning you can doif cmd; ...; fi
.