Re: process result code in if

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

 



----- 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" ;;
  *) echo integer ;;
esac

Again, when placing this in autoconf.ac, you need to quote the
[0-9] since m4 eats one level of [], either by writing [[0-9]]
in place, or by using [] around the entire case snippet.

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
https://lists.gnu.org/mailman/listinfo/autoconf




[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux