Skip to main content
11 events
when toggle format what by license comment
Jul 18, 2022 at 10:40 comment added dan @dolmen That's not correct. The behaviour is exactly the same under set -e. Except that if echo fails, the script will exit. [ -d "$DIR" ] alone (no && cmd ...) will cause the script to exit under set -e, if the test fails (ie. the directory does not exist, or $DIR exists but is not a directory).
S Feb 2, 2021 at 10:21 history suggested Lucas CC BY-SA 4.0
add a descriptive code comment; mark up code as shell
Jan 29, 2021 at 3:04 review Suggested edits
S Feb 2, 2021 at 10:21
Sep 4, 2018 at 16:03 comment added tzot @dolmen the [ -d "$DIR" ] is checked (followed by && echo Yes), so I believe set -e makes no difference to the script behaviour (i.e if the test fails, the script continues normally).
Jul 23, 2018 at 12:40 comment added dolmen The behavior is not the same under set -e (which is a shell programming best practice).
Oct 5, 2016 at 4:03 comment added tripleee cmd && other is a common shorthand for if cmd; then other; fi -- this works with most programming languages which support Boolean logic, and is known as short-circuit evaluation.
Aug 5, 2016 at 7:38 comment added Martijn Does this work like this: if $dir is a dir, then echo "yes"? A bit of explanation would help :)
May 25, 2015 at 13:13 history edited Jahid CC BY-SA 3.0
variable needs to be quoted to tackle with white spaces in path
Jul 30, 2013 at 11:36 history edited Aliaksandr Belik CC BY-SA 3.0
added 11 characters in body
Apr 12, 2013 at 17:29 history edited elmarco CC BY-SA 3.0
edited body
Sep 12, 2008 at 21:08 history answered elmarco CC BY-SA 2.5