sway

i3-compatible Wayland compositor
git clone https://git.awy.one/sway
Log | Files | Refs | README | LICENSE

commit 8ffa3cf43906fa95c127c01b751590e77c7bf695
parent 7f54495b5e62a65627cdb61f099e241f0594a6d9
Author: Manuel Mendez <mmendez534@gmail.com>
Date:   Sun, 17 Nov 2019 10:50:26 -0500

grimshot: fix branching on command exit status

The previous behavior was incorrect because `if` was checking the return
status of the `[` command which was never going to be an error. `[`
seems to only return an error if no args are provided. This was
basically a useless use of `[` anyway since it was just meant as a
straight interpretation of command exit, something that `if` can do
itself.

Compare:

```sh
[ ]; echo ?=$?
[ /bin/false ]; echo ?=$?
if [ /bin/false ]; then echo this is the unintended bug; fi
if /bin/false; then echo this will not be printed; fi
```

Diffstat:
Mcontrib/grimshot | 6++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/contrib/grimshot b/contrib/grimshot @@ -51,8 +51,7 @@ die() { check() { COMMAND=$1 - command -v "$COMMAND" > /dev/null 2>&1 - if [ $? ]; then + if command -v "$COMMAND" > /dev/null 2>&1; then RESULT="OK" else RESULT="NOT FOUND" @@ -102,8 +101,7 @@ if [ "$ACTION" = "copy" ] ; then rm "$TMP" notifyOk "$WHAT copied to buffer" else - takeScreenshot "$FILE" "$GEOM" - if [ $? ]; then + if takeScreenshot "$FILE" "$GEOM"; then TITLE="Screenshot of $SUBJECT" MESSAGE=$(basename "$FILE") notifyOk "$MESSAGE" "$TITLE"