3 ms·
> …left and single operands… That's false: x='foo bar'; [ $x = 'foo bar' ]; echo $? -bash: [: too many arguments x='foo bar'; [ "$x" = 'foo bar' ]; ech
by 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.