expr in Configure

bofh@snoopy.virtual.net.au
Tue, 21 Jan 97 03:55:02 +1000


I saw a message here which implied that expr was buggy because it couldn't
handle the scripts in the Linux kernel source (it had problems with parsing
ints). I reported it to the person who maintains the shellutils package for
Debian Linux and got the following response:

> I am having problems with shellutils 1.15-2. The program /usr/bin/expr does
> not work properly with the configure scripts that come with the linux kernel,
> on line 291 of scripts/configure I had to change:
> if expr "$ans" : '0$\|-?[1-9][0-9]*$' > /dev/null; then
> to:
> if expr "$ans" : '0$\|-\?[1-9][0-9]*$' > /dev/null; then
>
> On line 322 I had to change:
> if expr "$ans" : '[0-9a-fA-F]+$' > /dev/null; then
> to:
> if expr "$ans" : '[0-9a-fA-F]\+$' > /dev/null; then
>
> To enable me to enter integers without problem. A message on the linux-kernel
> mailing list states that this is due to a bug in expr. Is this true? If so
> what has to be done to get it fixed?

Not quite. It's due to a bug in expr that _was_ fixed. expr is now POSIX.2
complient, and the old expression depends on non-POSIX
behavior. expr is just fine--the kernel configuration script is
broken.

The denizens of linux-kernel should be aware of this. If they are not, if they
think it is a bug in expr (which you seem to imply)
somebody has to tell them *now*. Could you do that? I'm not on
the linux-kernel list.

Here's a quick patch I wrote for it:

*** linux/scripts/Configure.old Tue Jan 21 03:52:37 1997
--- linux/scripts/Configure Tue Jan 21 03:53:13 1997
***************
*** 288,294 ****
def=${old:-$3}
while :; do
readln "$1 ($2) [$def] " "$def" "$old"
! if expr "$ans" : '0$\|-?[1-9][0-9]*$' > /dev/null; then
define_int "$2" "$ans"
break
else
--- 288,294 ----
def=${old:-$3}
while :; do
readln "$1 ($2) [$def] " "$def" "$old"
! if expr "$ans" : '0$\|-\?[1-9][0-9]*$' > /dev/null; then
define_int "$2" "$ans"
break
else
***************
*** 319,325 ****
while :; do
readln "$1 ($2) [$def] " "$def" "$old"
ans=${ans#*[x,X]}
! if expr "$ans" : '[0-9a-fA-F]+$' > /dev/null; then
define_hex "$2" "$ans"
break
else
--- 319,325 ----
while :; do
readln "$1 ($2) [$def] " "$def" "$old"
ans=${ans#*[x,X]}
! if expr "$ans" : '[0-9a-fA-F]\+$' > /dev/null; then
define_hex "$2" "$ans"
break
else