[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: maybe feature, but still confusing...

From: Linda Walsh
Subject: Re: maybe feature, but still confusing...
Date: Sun, 10 Jul 2011 12:11:10 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv: Thunderbird/ Mnenhy/

Linda Walsh wrote:

Was trying a combo if statement with normal [[]] eval and an arith

in my ENV, (chose a number var at random), LINES=66

 echo "LINES=$LINES"
 if [[ -z "" && ((LINES == 66 )) ]]; then echo foo; fi

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

What am I missing?

I did find a a work around, even it it is a bit more verbose:

if ( [[ -z $dev1 || -z $dev2 ]] || ((dev1==0||dev2==0)) ); then echo not good; fi
(and another quirky looking one:
  if test -z $dev1 -o -z $dev2 || ((dev1==0||dev2==0)) ; then echo not good; fi
note you can't use the same type of "or" operator...I'm sure bean-counting
code-managers would LOVE that syntax...but it IS Shell, so....they can't 
too much!)...

I.e. setting
dev1=1 dev2=2 before either works
but dev1=1 dev2=0, prints 'not good'...

Just guessing but it's yet another 'special' case exception
to things inside of [[]] not working as expected...
(like the [[ "$a" =~ "two[ ]*words" ]] fiasco and having no way to group an
RE w/spaces...(other than first putting it in a var))

At least I understand that one now, though still don't agree with having no way to group an RE w/o using a var -- even if it was something 'rare', like ┬źdouble angle brackets┬╗.
But the above if, isn't using quotes OR the =~, so there must be something
else going on...  Are mathematical evals/expressions not allowed inside
[[]]? Was there a reason why that was considered

reply via email to

[Prev in Thread] Current Thread [Next in Thread]