Conditionals in POSIX standards

Solution 1:

Bash-specific

[[ .. ]]

POSIX = sh, like Dash

[ .. ]

As you also asked for personal opinion, mine is: If there is no reason to use the Bash-specific way, always try to adhere to POSIX standards.


Two examples

Comparing strings

in Bash

[[ "$a" == "$b" ]]

in a POSIX shell

[ "$a" = "$b" ]

While loop condition

in Bash

while [[ "$i" > 0 ]]

in a POSIX shell

while [ "$i" -gt 0 ]

Conclusion

While it may seem POSIX is rather harder to use, and it certainly may be at times, it gives you the power to move the script to any shell environment, i.e. portability. For example, you can run the same script on Windows in Cygwin and in any Linux shell.

I realize now, you specifically asked about the if conditional statements, and what I said is perfectly applicable to that question too.