
12 Dec
2011
12 Dec
'11
6:49 a.m.
On Sunday 04 December 2011 06:32:47 Marek Vasut wrote:
Should it be an equality operator instead of an assigning one? i.e:
[ "$ONLY_LIST" == "y" ] && return
- It's the same thing ... = and == in shell scripting.
while this is true for the particular piece of code quoted, in general, this statement is false. "==" is a bashism (it is not part of POSIX), and it allows you to do comparisons that the "=" operator does not (such as pattern matching).
this code uses "=" everywhere with single brackets. any new code should stick to that form. if you want to use "==", it should be with double brackets, and probably have a good reason for it. -mike