From 24a049508658a0304aae9026157d920c555dce1d Mon Sep 17 00:00:00 2001 From: Earnestly Date: Thu, 7 Dec 2017 15:38:44 +0000 Subject: [PATCH] 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. --- sx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sx b/sx index 54ff537..49220c8 100755 --- a/sx +++ b/sx @@ -12,7 +12,7 @@ cleanup() { # regardless of failure. set +o errexit - if test "$1" -a "$(ps -o comm= "$1")" = Xorg; then + if [ "$1" ] && [ "$(ps -o comm= "$1")" = Xorg ]; then kill "$1" # Send SIGKILL after 10 seconds if the xserver is taking too long to