Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • 4
    "Probably doesn't work"? Consider looking that up and make your statement a bit more certain. The issue with unquoted variables has to do with splitting and globbing. The fact that an unset variable causes issues if unquoted in a test is merely a consequence of this. What's wrong with using =? Commented Jan 10, 2021 at 7:17
  • I believe (( ... )) is standardized in POSIX, but I haven't found a description of Bourne shell features and doubt that it works in the Bourne shell. I'll leave it up to OP to look it up or otherwise confirm this. You are right that the issue with unquoted variables has to do with something, and my point is that it is an issue. Again you are right that test allows string comparison with =. Not so with arithmetic comparison, thoug, where -eq is required. Commented Jan 10, 2021 at 8:38
  • (( ... )) (arithmetic evaluation) is an extension to the POSIX standard. BTW, the standard is available here. You text currently says that "All operators ... are words with dashes" and that = (and &&) should not be used. Commented Jan 10, 2021 at 9:09
  • 1
    +1 for kiss answer and no wot (mods who deleted this comment, kiss - keep it simple stupid, wot - wall of text. this is coders language and no slang) while the accepted answer is more detailed, this answer was predecessor. it already contains basic differences, bash`s double brackets, quoted vars, operators. furthermore shellcheck is mentioned. i see no reason to downvote just for nitpicking Commented Jan 11, 2021 at 11:51