A.P. Horst
2013-06-06 09:00:51 UTC
Hi,
I am trying to do a simple check to validate a value is a positive
integer. There are many variations to do this but in general this should
do the trick:
var=100
if echo "$var" | grep -Eq '^[0-9]+$' > /dev/null 2>&1; then
echo "positive integer"
else
echo "something else"
fi
if I put this in a file and execute it, it works as expected. But if I
put it in my configure.ac, it doesn't work!
Also when I just have:
echo "$var" | grep -Eq '^[0-9]+$'
echo "$?"
the 'normal' script prints "0" if var is set to an integer and "1" when
set to something else. But the configure script prints "1" no matter
what I set var to.
I must be missing out on something because I took this construct from
another configure.ac which worked just fine.
I am on a win7 x64 machine with MinGW 3.20 and W32API 3.17
sh --version
GNU bash, version 3.1.17(1)-release (i686-pc-msys)
Arie
I am trying to do a simple check to validate a value is a positive
integer. There are many variations to do this but in general this should
do the trick:
var=100
if echo "$var" | grep -Eq '^[0-9]+$' > /dev/null 2>&1; then
echo "positive integer"
else
echo "something else"
fi
if I put this in a file and execute it, it works as expected. But if I
put it in my configure.ac, it doesn't work!
Also when I just have:
echo "$var" | grep -Eq '^[0-9]+$'
echo "$?"
the 'normal' script prints "0" if var is set to an integer and "1" when
set to something else. But the configure script prints "1" no matter
what I set var to.
I must be missing out on something because I took this construct from
another configure.ac which worked just fine.
I am on a win7 x64 machine with MinGW 3.20 and W32API 3.17
sh --version
GNU bash, version 3.1.17(1)-release (i686-pc-msys)
Arie