[Libreoffice] Quoting issue in autogen.sh

Thomas Klausner wiz at NetBSD.org
Mon Oct 4 16:07:40 PDT 2010


On Mon, Oct 04, 2010 at 08:37:02PM +0200, Jan Nieuwenhuizen wrote:
> It seems to work for me, so I first would have to be able to
> reproduce it: 

I've analyzed the problem further. It appears on at least NetBSD and
Mac OS X (according to reports on irc).

The issue on NetBSD is that sed by default expects basic regex; and
basic regex don't support '|'.

How does this change work for people (explanation of the regex see below[1])?

 requote_args ()
 {
-    sed -e 's/.*configure //' -e 's/=\(\([^"'"'"'-]\|-[^-]\| \)*\)\( \|$\)/="\1
+    sed -r -e 's/.*configure //' -e 's/=(([^"'"'"'-]|-[^-]| )*)( |$)/="\1" /g'
 }

Worked for Fridrich last night (for who my previous try at fixing
this broke stuff) and works for me on NetBSD.

Diffs for main and clone/bootstrap gits attached (restoring to version
from Oct 3 i.e. before all the recent changes, and applying the fix
above and a quoting fix).

One remaining issue:
./autogen.sh --arg=value CFLAGS=foo
doesn't work with the regex, because it becomes something like:
./configure '--arg=value CFLAGS=foo'
I'm not yet sure how to fix that.
 Thomas

[1] Regex in words: after an equal sign, take
1. everything but double quote, single quote, and dash OR
2. dash but only if it's not dash dash (next option starts with dash dash)
3. a space (actually, shouldn't be necessary, since 1. will match that as well)
until you hit a space or the end of the arguments)

and replace it with whatever you found in between double quotes and
add a space.

-------------- next part --------------
diff --git a/autogen.sh b/autogen.sh
index 85e8278..72785bc 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -13,9 +13,11 @@ fi
 
 requote_args ()
 {
-    sed -e 's/.*configure //' -e 's/=\(\([^"'"'"'-]\|-[^-]\| \)*\)\( \|$\)/="\1" /g'
+    sed -r -e 's/.*configure //' -e 's/=(([^"'"'"'-]|-[^-]| )*)( |$)/="\1" /g'
 }
 
+new_args=`echo "$@" | requote_args`
+
 old_args=""
 if test $# -eq 0 && test -f config.log; then
     old_args=`grep '\$ ./configure' config.log | requote_args`
@@ -29,7 +31,7 @@ automake --gnu --add-missing --copy --warnings=no-portability || exit 1;
 # intltoolize --copy --force --automake
 autoconf || exit 1;
 if test "x$NOCONFIGURE" = "x"; then
-    eval `echo ./configure $old_args "$@"`
+    eval `echo ./configure $new_args $old_args`
 else
     echo "Skipping configure process."
 fi
diff --git a/bin/build-ooo b/bin/build-ooo
index 8e63912..d437e8e 100755
--- a/bin/build-ooo
+++ b/bin/build-ooo
@@ -50,8 +50,7 @@ echo "Env for configure:"
 set
 echo "Env for configure ends"
 
-NOCONFIGURE=indeed sh ./autogen.sh
-eval ./configure "$CONFIGURE_OPTIONS" "$PROPAGATED_ARGS" || exit 1;
+eval ./autogen.sh "$CONFIGURE_OPTIONS" "$PROPAGATED_ARGS" || exit 1;
 
 # Final build preparation
 
-------------- next part --------------
diff --git a/autogen.sh b/autogen.sh
index 2725f16..86011f1 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -11,10 +11,10 @@ fi
 
 requote_args ()
 {
-    sed -e 's/.*configure //' -e 's/=\(\([^"'"'"'-]\|-[^-]\| \)*\)\( \|$\)/="\1" /g'
+    sed -r -e 's/.*configure //' -e 's/=(([^"'"'"'-]|-[^-]| )*)( |$)/="\1" /g'
 }
 
-new_args=`echo $@ | requote_args`
+new_args=`echo "$@" | requote_args`
 
 old_args=""
 if test $# -eq 0 && test -f config.log; then


More information about the LibreOffice mailing list