[Top][All Lists]

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

process result code in if

From: A.P. Horst
Subject: process result code in if
Date: Thu, 06 Jun 2013 11:00:51 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130509 Thunderbird/17.0.6


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:
if echo "$var" | grep -Eq '^[0-9]+$' > /dev/null 2>&1; then
    echo "positive integer"
    echo "something else"

if I put this in a file and execute it, it works as expected. But if I put it in my, 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 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)


reply via email to

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