![]() |
Which test syntax to use?
I found out that you can use [ test-condition ] or [[ test-condition ]] in shell scripts . To me the [[ test-condition ]] syntax seems to resemble other programming lanuage syntax by support && and || logical operators. Is one syntax preferred over the other?
|
There is no "preference". [[ ]] is required for tests that support booleans like || and &&.
I am assuming you mean either bash or ksh here. |
I've used single brackets with || and &&.
|
Quote:
You can also use -o :
if [ $a -eq 0 -o $b -eq 0 ] ; then |
I personally find using || and && with [[ ]] to be a more "natural way" of testing a condition as opposed to -o and -a using [ ].
|
| All times are GMT -5. The time now is 4:43 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC