mirror of
https://github.com/swaywm/sway.git
synced 2024-11-22 16:01:27 +00:00
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 ```
This commit is contained in:
parent
7f54495b5e
commit
8ffa3cf439
|
@ -51,8 +51,7 @@ die() {
|
||||||
|
|
||||||
check() {
|
check() {
|
||||||
COMMAND=$1
|
COMMAND=$1
|
||||||
command -v "$COMMAND" > /dev/null 2>&1
|
if command -v "$COMMAND" > /dev/null 2>&1; then
|
||||||
if [ $? ]; then
|
|
||||||
RESULT="OK"
|
RESULT="OK"
|
||||||
else
|
else
|
||||||
RESULT="NOT FOUND"
|
RESULT="NOT FOUND"
|
||||||
|
@ -102,8 +101,7 @@ if [ "$ACTION" = "copy" ] ; then
|
||||||
rm "$TMP"
|
rm "$TMP"
|
||||||
notifyOk "$WHAT copied to buffer"
|
notifyOk "$WHAT copied to buffer"
|
||||||
else
|
else
|
||||||
takeScreenshot "$FILE" "$GEOM"
|
if takeScreenshot "$FILE" "$GEOM"; then
|
||||||
if [ $? ]; then
|
|
||||||
TITLE="Screenshot of $SUBJECT"
|
TITLE="Screenshot of $SUBJECT"
|
||||||
MESSAGE=$(basename "$FILE")
|
MESSAGE=$(basename "$FILE")
|
||||||
notifyOk "$MESSAGE" "$TITLE"
|
notifyOk "$MESSAGE" "$TITLE"
|
||||||
|
|
Loading…
Reference in a new issue