On Tue, 27 Oct 2020 at 10:56, David Wright <deb...@lionunicorn.co.uk> wrote:
> fuser -v "$j" > [ $? -ne 0 ] && gzip "$j" && mv -i "$j.gz" "$HOME/.monitors/xsession/" [...] > (Script improvements always appreciated.) Hi, you might be interested in the info below : my test script: """ #!/bin/sh [ $? -ne 0 ] && echo hi """ https://www.shellcheck.net says: """ Line 2: [ $? -ne 0 ] && echo hi ^-- SC2181: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?. """ https://github.com/koalaman/shellcheck/wiki/SC2181 says: """ Running a command and then checking its exit status $? against 0 is redundant. Instead of just checking the exit code of a command, it checks the exit code of a command (e.g. [) that checks the exit code of a command. """