process result code in if

2013-06-06 Thread A.P. Horst
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

Re: process result code in if

2013-06-06 Thread Earnie Boyd
On Thu, Jun 6, 2013 at 5:00 AM, A.P. Horst wrote: > Also when I just have: > echo "$var" | grep -Eq '^[0-9]+$' > echo "$?" -->8-- > 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) How is the var variable set? If you're

Re: process result code in if

2013-06-06 Thread Keith Marshall
On 6 June 2013 12:12, Earnie Boyd wrote: > On Thu, Jun 6, 2013 at 5:00 AM, A.P. Horst wrote: > > Also when I just have: > > echo "$var" | grep -Eq '^[0-9]+$' > > echo "$?" > -->8-- > > I am on a win7 x64 machine with MinGW 3.20 and W32API 3.17 > > sh --version > > GNU bash, version 3.1.17(1)-relea

Re: process result code in if

2013-06-06 Thread Keith Marshall
On 6 June 2013 12:54, Keith Marshall wrote: > On 6 June 2013 12:12, Earnie Boyd wrote: > >> On Thu, Jun 6, 2013 at 5:00 AM, A.P. Horst wrote: >> > Also when I just have: >> > echo "$var" | grep -Eq '^[0-9]+$' >> > ... >> >> How is the var variable set? If you're using the output of a compiled >>

Re: process result code in if

2013-06-06 Thread Eric Blake
- Original Message - > > A more robust, (and more portable), formulation may be: > > echo $var | grep '^+\{0,1\}[0-9]\{1,\}$' > /dev/null 2>&1 Why fork, when straight shell will do? case $var in +*) tmp=$var ;; *) tmp=+$var ;; esac case $tmp in +*[!0-9]* | +) echo "not numeric"

Re: process result code in if

2013-06-06 Thread Keith Marshall
On 6 June 2013 13:41, Eric Blake wrote: > > A more robust, (and more portable), formulation may be: > > > > echo $var | grep '^+\{0,1\}[0-9]\{1,\}$' > /dev/null 2>&1 > > Why fork, when straight shell will do? > > case $var in > ... > Agreed, avoiding the fork is a good idea, and I do often us

test for CXXLD

2013-06-06 Thread Nicolas Bock
Hi, The C++ compiler I am using (charmc) needs an additional command line argument during the linker stage (-language charm++). I am unsure how to best add this argument. The generated makefiles use CXX for compilation and CXXLD for linking, both of which are set to "charmc". How would I change CX

Re: test for CXXLD

2013-06-06 Thread Gavin Smith
On Thu, Jun 6, 2013 at 8:08 PM, Nicolas Bock wrote: > Hi, > > The C++ compiler I am using (charmc) needs an additional command line > argument during the linker stage (-language charm++). I am unsure how to > best add this argument. The generated makefiles use CXX for compilation and > CXXLD for l

implement workaround for header files

2013-06-06 Thread Peter Johansson
Hi autoconfers, I have the following case: I maintain a library that uses boost heavily. Recently I learnt that is broken with certain version of GCC (4.4.7 for example). I would like provide a workaround for users of the library (myself e.g.) so we won't even notice the breakage. I've imple

Re: process result code in if

2013-06-06 Thread Miles Bader
Wait, why can't you use "test $x -gt 0"...? -miles -- Logic, n. The art of thinking and reasoning in strict accordance with the limitations and incapacities of the human misunderstanding. ___ Autoconf mailing list Autoconf@gnu.org https://lists.gnu.or

Re: process result code in if

2013-06-06 Thread Gary V. Vaughan
On 7 Jun 2013, at 08:41, Miles Bader 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! Cheers, -- Gary V. Vaughan (gary AT gnu DOT org) ___ Autoconf maili

Re: process result code in if

2013-06-06 Thread Miles Bader
"Gary V. Vaughan" writes: > On 7 Jun 2013, at 08:41, Miles Bader 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

Re: process result code in if

2013-06-06 Thread A.P. Horst
On 7-6-2013 5:13, Miles Bader wrote: "Gary V. Vaughan" writes: On 7 Jun 2013, at 08:41, Miles Bader 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 th

Re: process result code in if

2013-06-06 Thread Miles Bader
"A.P. Horst" writes: > I ended up using this: > if ! test $var -gt 0 > /dev/null 2>&1; then Incidentally, test should never produce any output on stdout, so you can just use "2>/dev/null" instead of "> /dev/null 2>&1"... :] -miles -- P.S. All information contained in the above letter is false