3 ms·
Hello fellow traveler. I've got 20 years of scripts with `if test` in them. I only use `[[` when I need functionality it provides that `test` does not (pattern
by js2 3y ago
Hello fellow traveler. I've got 20 years of scripts with `if test` in them. I only use `[[` when I need functionality it provides that `test` does not (pattern or regex matching, typically, and for pattern matching I'll generally use a case statement instead).
- chatmasta 3y agoYeah that's when I use it too. I figure if I've already given into the temptations of Bash, I may as well go all the way. Sometimes if I'm feeling extra frisky I even do [[ .. ]] || { echo "error!" ; exit 1 }
- cduzz 3y agoI imagine most people have sets of macros they habitually add to any sufficiently complex script they're modifying... yelp(){ es=$1 shift echo "$@" >&2 exit $es } test -d /tmp/goober || yelp 33 "couldn't find goober!" (yes, I'm sure there are standards for exit status ranges and 33 is not such a thing)