Some implementations of test(1), in an attempt to be smart, provide non-standard operators such as ==. Please forget about those: they make your scripts non-portable and a pain to use in other systems. Why? Because, due to the way the shell works, failures in calls to test(1) will often just result in an error message (which may not be seen due to other output) and the script will happily continue running even if it missed to perform some important operation.

So... just use the standard equality operators:
  • = for string equality comparison.
  • -eq for numeric equality comparison.
Note that whenever I refer to test(1), I'm also talking about the [ ... ] construction in conditionals.

Also, please note that this also affects configure scripts, and the problem in these appears much more commonly than in other scripts!

Go to posts index

Comments from the original Blogger-hosted post: