Bo Ørsted Andresen wrote:

> On Monday 24 September 2007 21:56:49 Donnie Berkholz wrote:
>> > if [[ "$(gcc-major-version)" -gt "3" ]] || \
>> > ( [[ "$(gcc-major-version)" -eq "3" ]] && [[ "$(gcc-minor-version)" -gt
>> > "3" ]] )
>>
>> Code block { } might be good here instead of a subshell, or perhaps it
>> could use logic that's less convoluted such as if..then. Also don't need
>> the double quotes.
> 
> Or it could be as simple as:
> 
> if [[ $(gcc-major-version) -gt 3 || \
>     ( $(gcc-major-version) -eq 3 && $(gcc-minor-version) -gt 3 ) ]]
> 
> [[ allows grouping of conditions without spawning subshells.
> 
http://wooledge.org/mywiki/BashFAQ#faq31 explains the differences between [[
and [, although in this case I'd use:
if ((gcc-major-version>3 || (gcc-major-version==3 && gcc-minor-version>3) ))

"As a rule of thumb, [[ is used for strings and files. If you want to
compare numbers, use an ArithmeticExpression."


-- 
[EMAIL PROTECTED] mailing list

Reply via email to