4 ms·
It's true, but you're semantically overloading the variable syntax (by hinting that it's treated as string). Plus, left and single operands, in bash conditions
by pizza234 6y ago
It's true, but you're semantically overloading the variable syntax (by hinting that it's treated as string).
Plus, left and single operands, in bash conditions, don't require quoting, so a lean style is actually not to use them at all.
- tempodox 6y ago> …left and single operands… That's false: x='foo bar'; [ $x = 'foo bar' ]; echo $? -bash: [: too many arguments x='foo bar'; [ "$x" = 'foo bar' ]; echo $? 0
- gravitas 6y agoAs I replied to your other comment, you cannot just replace [[ with [ and get the same behaviour. If you use the actual bash builtin [[ which we're discussing, it works as expected. Also, please use == when comparing, = is an assignment operator (in almost every programming language).
- tempodox 6y agoMy bad. I interpreted “bash conditions” differently.