aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorLibravatar Manuel Mendez <mmendez534@gmail.com>2019-11-17 10:50:26 -0500
committerLibravatar Simon Ser <contact@emersion.fr>2019-11-17 17:18:54 +0100
commit8ffa3cf43906fa95c127c01b751590e77c7bf695 (patch)
tree3463efce4786c8cdce92a1e17acbad151346e36d /contrib
parentUse an enum instead of a marker string for map_to_ (diff)
downloadsway-8ffa3cf43906fa95c127c01b751590e77c7bf695.tar.gz
sway-8ffa3cf43906fa95c127c01b751590e77c7bf695.tar.zst
sway-8ffa3cf43906fa95c127c01b751590e77c7bf695.zip
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 (limited to 'contrib')
-rwxr-xr-xcontrib/grimshot6
1 files changed, 2 insertions, 4 deletions
diff --git a/contrib/grimshot b/contrib/grimshot
index de2e7a7f..8a253ce8 100755
--- a/contrib/grimshot
+++ b/contrib/grimshot
@@ -51,8 +51,7 @@ die() {
51 51
52check() { 52check() {
53 COMMAND=$1 53 COMMAND=$1
54 command -v "$COMMAND" > /dev/null 2>&1 54 if command -v "$COMMAND" > /dev/null 2>&1; then
55 if [ $? ]; then
56 RESULT="OK" 55 RESULT="OK"
57 else 56 else
58 RESULT="NOT FOUND" 57 RESULT="NOT FOUND"
@@ -102,8 +101,7 @@ if [ "$ACTION" = "copy" ] ; then
102 rm "$TMP" 101 rm "$TMP"
103 notifyOk "$WHAT copied to buffer" 102 notifyOk "$WHAT copied to buffer"
104else 103else
105 takeScreenshot "$FILE" "$GEOM" 104 if takeScreenshot "$FILE" "$GEOM"; then
106 if [ $? ]; then
107 TITLE="Screenshot of $SUBJECT" 105 TITLE="Screenshot of $SUBJECT"
108 MESSAGE=$(basename "$FILE") 106 MESSAGE=$(basename "$FILE")
109 notifyOk "$MESSAGE" "$TITLE" 107 notifyOk "$MESSAGE" "$TITLE"