bug-bash
[Top][All Lists]
Advanced

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

Question about testing with variable operators


From: Steven W. Orr
Subject: Question about testing with variable operators
Date: Fri, 10 Jun 2011 11:44:42 -0400
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10

I am using arithmetic tests where the test operator is passed in as an arg and it works just fine.

foo()
{
    (( $1 $2 $3 ))
}

foo 5 '>' 7

But I figured that if this works for arithmetic, it should also work with the test operator. It seems to not work:

514 > bar()
> {
>     [[ $1 $2 ]]
bash: conditional binary operator expected
bash: syntax error near `$2'

As a work around, I can use eval or the builtin test, but my question is this: Is this a bug or is there a reason that it should work for arithmetic but not for the test [[ operator?

GNU bash, version 4.0.35(1)-release (x86_64-redhat-linux-gnu)

TIA

--
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net



reply via email to

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