On 7-6-2013 5:13, Miles Bader wrote:
"Gary V. Vaughan" <gary@xxxxxxx> writes:
On 7 Jun 2013, at 08:41, Miles Bader <miles@xxxxxxx> 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
_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
https://lists.gnu.org/mailman/listinfo/autoconf