In a corner with no where to go, giving demerits because his bash was older than he realized.
Reminds me of my college professor that claimed you don’t have to close HTML tags (some you absolutely do) and I proved that you do. Not all of them, but most of them. (Netscape Navigator Days)
The author’s professor clearly went gone overboard, but doesn’t this entire anecdote demonstrate the value of teaching it this way? Having green students call the `test` binary provides more insight into how UNIX operates, and gets them into that mindset.
$ which [
/bin/[
$ type [
[ is a shell builtin
The same is true for the `test` command: $ which test
/bin/test
$ type test
test is a shell builtin if "[" "$foo" "==" "bar" "]"; then ...
theandrewbailey•1h ago
I'm still not sure when to use one or the other. I use double brackets by default until something doesn't work.
stabbles•1h ago
When unsure, use shellcheck.
a3w•1h ago
duskdozer•59m ago
PhilipRoman•1h ago
ndsipa_pomu•7m ago
I personally use ((...)) for arithmetic tests and [[...]] for all other tests as I just target new versions of BASH and don't care much about POSIX compatibility.
nickjj•30m ago
I usually default to [ ... ] unless I need features that double brackets provide.
ndsipa_pomu•6m ago
jonhohle•1m ago