Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> …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


As 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).


My bad. I interpreted “bash conditions” differently.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: