Andreas Schwab wrote:

Linda Walsh <b...@tlinx.org> writes:

 if [[ -z "" && ((LINES < 80 )) ]]; then echo foo; fi
(prints nothing)....

What am I missing?

"LINES" does not sort before "80".

Andreas.


But it compares == to 66?

Normally, in the shell, if you type in something in double parens
it does a mathematical evaluation.

i.e.
if you are in a while loop

lines=0
while read foobar; {
   ((++lines))  #increments value of lines by 1
   ((lines>23)) && break;  #and quits if more than 23 lines are read
}


so I'd expect the above to eval my shell-var, 'lines'...
Ah....I see....I need another set of parens!...
(ARG....!!....
What rule should I have remembered to 'know' that?

'if in [[ ]], then you need an extra level of parens around a double-paren
expression to get mathematical evaluation'...

(seems like a pretty specific rule (i.e. does it generalize from something?))

I guess many of us are still learning about these things as they unfold --
and of course Chet keeps ahead of us by continually throwing in more benefits...
(if we can decipher them!)...

-l

Reply via email to