Skip to contentSkip to conversation

patch: configure: nonstandard use of `expr'

Qemu-devel Juergen Lock 2 participants 3 messages Apr 27, 2006

lore
Share & tools
lore
#0 lore raw

At least FreeBSD's expr(1) doesnt understand the syntax now used in configure:

Index: qemu/configure
@@ -157,7 +157,7 @@
fi

for opt do
- optarg=expr "$opt" : '[^=]*=\(.*\)'
+ optarg=echo "$opt" |sed 's/^[^=]*=//'
case "$opt" in
--help|-h) show_help=yes
;;

#1 lore raw

Review line 163

Quoted 13 lines · Juergen Lock

At least FreeBSD's expr(1) doesnt understand the syntax now used in configure:

Index: qemu/configure

(quoted diff) +1 -1
@@ -157,7 +157,7 @@
 fi
 
 for opt do
-  optarg=`expr "$opt" : '[^=]*=\(.*\)'`
+  optarg=`echo "$opt" |sed 's/^[^=]*=//'`
   case "$opt" in
   --help|-h) show_help=yes
   ;;

The GNU Autoconf manual, and its code, recommends something like this (note the "x" prefix):

optarg=expr "x$opt" : 'x[^=]*=\(.*\)'

Your echo version suffers from non-portable results when opt matches "-n*", "-e*", "-E*", or something with a backslash in.

-- Jamie

#2 lore raw

In article <[email protected]> you write:

Quoted 18 lines

Review line 163

Quoted 13 lines · Juergen Lock

At least FreeBSD's expr(1) doesnt understand the syntax now used in configure:

Index: qemu/configure

(quoted diff) +1 -1
@@ -157,7 +157,7 @@
 fi
 
 for opt do
-  optarg=`expr "$opt" : '[^=]*=\(.*\)'`
+  optarg=`echo "$opt" |sed 's/^[^=]*=//'`
   case "$opt" in
   --help|-h) show_help=yes
   ;;

The GNU Autoconf manual, and its code, recommends something like this (note the "x" prefix):

Quoted 4 lines

optarg=expr "x$opt" : 'x[^=]*=\(.*\)'

Your echo version suffers from non-portable results when opt matches "-n*", "-e*", "-E*", or something with a backslash in.

Oh, indeed. Better version:

Index: qemu/configure
@@ -157,7 +157,7 @@
fi

for opt do
- optarg=expr "$opt" : '[^=]*=\(.*\)'
+ optarg=echo "x$opt" |sed 's/^[^=]*=//'
case "$opt" in
--help|-h) show_help=yes
;;