sx: test -a may not be short-circuiting

I was under the false assumption that -a, like &&, was used
short-circuit semantics.  However the behaviour of -a is not specified
by POSIX.

At least on Linux using bash or dash the behaviour is not
short-circuiting.

As there's no reason to test the RHS if the LHS is false I've switched
back to [ ] && notation which is defined to be short-circuiting.
This commit is contained in:
Earnestly 2017-12-07 15:38:44 +00:00
parent f783766e2c
commit 24a0495086
1 changed files with 1 additions and 1 deletions

2
sx
View File

@ -12,7 +12,7 @@ cleanup() {
# regardless of failure. # regardless of failure.
set +o errexit set +o errexit
if test "$1" -a "$(ps -o comm= "$1")" = Xorg; then if [ "$1" ] && [ "$(ps -o comm= "$1")" = Xorg ]; then
kill "$1" kill "$1"
# Send SIGKILL after 10 seconds if the xserver is taking too long to # Send SIGKILL after 10 seconds if the xserver is taking too long to