Re: sh-utils expr 1.15 regexp bug

Noah Friedman (friedman@splode.com)
Wed, 12 Feb 1997 15:46:35 -0800


>> It used to be the case that the expression
>>
>> expr 100 : '0$\|-?[1-9][0-9]*'
>>
>> Would print 3. This worked with sh-utils 1.12.
>>
>> With 1.15, it prints 0 unless I remove "-?" from the regexp, or replace it
>> with `*', which isn't exactly right.
>>
>> Isn't `?' a part of the old grep syntax for matching the preceding
>> character or group 0 or 1 times? Was this functionality removed
>> deliberately? It's breaking the linux kernel configuration scripts.
>
>I've experienced this too...It affects two lines in Menuconfig only. The
>reply given me by the maintainer of sh-utils was to add a "\" before the ?
>as suggested in the other reply to your post.

Yes, but then people with older versions of expr will lose, because \? will
be interpreted as a normal character.

For portability, I think we may be resigned to using

expr $value : '0\|-[1-9][0-9]*\|[1-9][0-9]*'