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
>> program, I'm guessing the issue is CRLF versus just LF. ...
>>
>
> Another (more likely) possibility is that the shell fragment is under
> quoted, where it appears in configure.ac. ...
>
BTW, even when you've corrected the under quoting issue, this
echo $var | grep -Eq '^[0-9]+$'
test that $var represents a positive integer doesn't really "cut the
mustard"; there are two reasons:
1) It completely neglects to consider any initial unary + sign, so
would reject any representation such as var=+50
2) grep -Eq ... is not portable; not all implementations of grep support
GNU grep's -E and -q options.
A more robust, (and more portable), formulation may be:
echo $var | grep '^+\{0,1\}[0-9]\{1,\}$' > /dev/null 2>&1
--
Regards,
Keith.
_______________________________________________
Autoconf mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/autoconf