Skip to contentSkip to conversation

configure: replace \n with space in optarg

PATCH In review Hu Tao 2 participants 3 messages Aug 4, 2014

lore
Share & tools
lore

Hu Tao

author
#0 lore raw

PATCH 1/1 configure: replace \n with space in optarg

When optarg happens to contain \n like:

../configure --target-list='i386-softmmu
x86_64-softmmu'

make will fail with message:

config-host.mak:45: *** missing separator. Stop.

This patch fix this problem by replacing \n with space in optarg.

---
 configure | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
configure +2 -2
index f7685b5..0ee9de1 100755
@@ -338,7 +338,7 @@ numa=""
 
 # parse CC options first
 for opt do
-  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
+  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)' | tr '\n' ' '`
   case "$opt" in
   --cross-prefix=*) cross_prefix="$optarg"
   ;;
@@ -722,7 +722,7 @@ fi
 werror=""
 
 for opt do
-  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
+  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)' | tr '\n' ' '`
   case "$opt" in
   --help|-h) show_help=yes
   ;;
Signature · 1 line
1.9.3
#1 lore raw
Quoted 8 lines · Hu Tao

When optarg happens to contain \n like:

../configure --target-list='i386-softmmu
x86_64-softmmu'

make will fail with message:

config-host.mak:45: *** missing separator. Stop.

Why would you put newlines in the option string? This is likely to break for many configure arguments, not just this one...

I'm a bit dubious about taking this change unless you can point to existing practice (eg do autoconf configure scripts clean up whitespace like this?)

thanks
-- PMM

author
#2 lore raw
Quoted 6 lines · Peter Maydell
Quoted 5 lines · Hu Tao

When optarg happens to contain \n like:

../configure --target-list='i386-softmmu
x86_64-softmmu'

Quoted 7 lines
Quoted 3 lines

make will fail with message:

config-host.mak:45: *** missing separator. Stop.

Why would you put newlines in the option string? This is likely to break for many configure arguments, not just this one...

It is not intended but once when I did copy&paste the string it brought a \n.

Quoted 4 lines

I'm a bit dubious about taking this change unless you can point to existing practice (eg do autoconf configure scripts clean up whitespace like this?)

I doubt there is.

Quoted 3 lines

thanks
-- PMM