1 |
Bo Ørsted Andresen wrote: |
2 |
|
3 |
> On Monday 24 September 2007 21:56:49 Donnie Berkholz wrote: |
4 |
>> > if [[ "$(gcc-major-version)" -gt "3" ]] || \ |
5 |
>> > ( [[ "$(gcc-major-version)" -eq "3" ]] && [[ "$(gcc-minor-version)" -gt |
6 |
>> > "3" ]] ) |
7 |
>> |
8 |
>> Code block { } might be good here instead of a subshell, or perhaps it |
9 |
>> could use logic that's less convoluted such as if..then. Also don't need |
10 |
>> the double quotes. |
11 |
> |
12 |
> Or it could be as simple as: |
13 |
> |
14 |
> if [[ $(gcc-major-version) -gt 3 || \ |
15 |
> ( $(gcc-major-version) -eq 3 && $(gcc-minor-version) -gt 3 ) ]] |
16 |
> |
17 |
> [[ allows grouping of conditions without spawning subshells. |
18 |
> |
19 |
http://wooledge.org/mywiki/BashFAQ#faq31 explains the differences between [[ |
20 |
and [, although in this case I'd use: |
21 |
if ((gcc-major-version>3 || (gcc-major-version==3 && gcc-minor-version>3) )) |
22 |
|
23 |
"As a rule of thumb, [[ is used for strings and files. If you want to |
24 |
compare numbers, use an ArithmeticExpression." |
25 |
|
26 |
|
27 |
-- |
28 |
gentoo-dev@g.o mailing list |