autoconf
[Top][All Lists]
Advanced

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

Re: process result code in if


From: A.P. Horst
Subject: Re: process result code in if
Date: Fri, 07 Jun 2013 08:08:09 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130509 Thunderbird/17.0.6


On 7-6-2013 5:13, Miles Bader wrote:
"Gary V. Vaughan" <address@hidden> writes:
On 7 Jun 2013, at 08:41, Miles Bader <address@hidden> wrote:
Wait, why can't you use "test $x -gt 0"...?
You mean "test 0 -lt $x", otherwise if x starts with a hyphen (e.g -1)
things will go awry!
I dunno, test here (both coreutils test, and the bash builtin) seems
to handle negative numbers just fine using "test $x -gt 0" ...

[I suppose maybe there are broken versions of test out there, the
usual issue with just about anything in autoconf... typically Sun... >< ]

-miles


Thanks for all the great input! Seems google isn't always your best friend, at least not when it comes to autoconf. The solution with the test command is very elegant and readable.
I ended up using this:
if ! test $var -gt 0 > /dev/null 2>&1; then
    <not a positive integer>
fi

This works also when something else than a number or nothing at all is given.

I will try to remember autoconf also eats brackets.

arie



reply via email to

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