More on Conditionals

  • + 2 comments

    Yes, the chart is incorrect. man test shows the correct operators.

    Technically, = is for strings, and -eq is for integers. Using = on integers compares them as strings, since bash is weakly typed. Often this won't have much of an impact, but you can see the difference by testing [ 0 = 00 ] vs [ 0 -eq 00 ].

    Best practice is to use the correct operator so that when you hit the weird edge cases, you don't lose hair looking for a hard-to-find bug.