I think it would be valuable to explicitly talk about whitespace requirements in [ ] and [[ ]] conditionals--this tripped me up when learning Bash and I know it's a pain point for a lot of developers.
The way I like to think about it is that [ and [[ are commands/builtins (like echo, etc), as opposed to being part of Bash syntax. For this reason, the command name and each of its arguments must be separated by whitespace:
I think it would be valuable to explicitly talk about whitespace requirements in
[ ]
and[[ ]]
conditionals--this tripped me up when learning Bash and I know it's a pain point for a lot of developers.The way I like to think about it is that
[
and[[
are commands/builtins (likeecho
, etc), as opposed to being part of Bash syntax. For this reason, the command name and each of its arguments must be separated by whitespace: