]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Fix the handling of `./configure foo=bar' and test it.
authorAkim Demaille <akim@epita.fr>
Wed, 9 Feb 2000 18:24:24 +0000 (18:24 +0000)
committerAkim Demaille <akim@epita.fr>
Wed, 9 Feb 2000 18:24:24 +0000 (18:24 +0000)
* acgeneral.m4 (AC_INIT_PARSE_ARGS, getopt loop): Always define
ac_optarg as the rhs of the first `=', not only on `-.*=', so that
`configure var=val' defines ac_optarg=val.
Improve the robustness to shell special characters:
 - Use grep when checking that shell variable names are valid.
 - Quote the quotes in ac_optarg before `eval var='$ac_optarg''.
 - Quote the quotes when building ac_configure_args.

* tests/torture.m4: Test that `./configure foo=bar' works properly.

ChangeLog
acgeneral.m4
lib/autoconf/general.m4
tests/torture.m4

index d22d1d3f30b08c1068532af2a2bc6aefc0c13e7d..bb08601f87543d55fc503e9a1762a16e6dfa1e93 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2000-02-09  Akim Demaille  <akim@epita.fr>
+
+       Fix the handling of `./configure foo=bar' and test it.
+
+       * acgeneral.m4 (AC_INIT_PARSE_ARGS, getopt loop): Always define
+       ac_optarg as the rhs of the first `=', not only on `-.*=', so that
+       `configure var=val' defines ac_optarg=val.
+       Improve the robustness to shell special characters:
+        - Use grep when checking that shell variable names are valid.
+        - Quote the quotes in ac_optarg before `eval var='$ac_optarg''.
+        - Quote the quotes when building ac_configure_args.
+
+       * tests/torture.m4: Test that `./configure foo=bar' works properly.
+
 2000-02-09  Akim Demaille  <akim@epita.fr>
 
        Resynchronize `INSTALL' with the current `configure', and
index 7b812803a89731b0ac91664dd34c30078cd96873..976b150aea921a11f81e80cdedc4cb563c4c2d38 100644 (file)
@@ -627,12 +627,7 @@ do
     continue
   fi
 
-  case "$ac_option" in
-changequote(, )dnl
-  -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
-changequote([, ])dnl
-  *) ac_optarg= ;;
-  esac
+[  ac_optarg=`echo "$ac_option" | sed -n 's/^[^=]*=//p'`]
 
   # Accept the important Cygnus configure options, so we can diagnose typos.
 
@@ -975,14 +970,15 @@ changequote([, ])dnl
     ;;
 
   *=*)
-    ac_envvar=`echo $ac_option|sed -e 's/=.*//'`
+    ac_envvar=`echo "$ac_option" | sed -e 's/=.*//'`
     # Reject names that are not valid shell variable names.
 changequote(, )dnl
-    if test -n "`echo $ac_envvar| sed 's/[_a-zA-Z0-9]//g'`"; then
+    if echo "$ac_envvar" | grep '[^a-zA-Z0-9_]' >/dev/null 2>&1; then
 changequote([, ])dnl
       AC_MSG_ERROR($ac_envvar: invalid variable name)
     fi
-    eval "${ac_envvar}='$ac_optarg'"
+    ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`
+    eval "$ac_envvar='$ac_optarg'"
     export $ac_envvar ;;
 
   *)
@@ -1097,8 +1093,8 @@ do
 changequote(<<, >>)dnl
 dnl If you change this globbing pattern, test it on an old shell --
 dnl it's sensitive.  Putting any kind of quote in it causes syntax errors.
-  *" "*|*"     "*|*[\[\]\~\<<#>>\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
-  ac_arg=`echo "$ac_arg"|sed "s/'/'\\\\\\\\''/g"`
+  *" "*|*"     "*|*[\[\]\~\<<#>>\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
+  ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"`
   ac_configure_args="$ac_configure_args '$ac_arg'" ;;
 changequote([, ])dnl
   *) ac_configure_args="$ac_configure_args $ac_arg" ;;
@@ -3387,8 +3383,8 @@ Report bugs to <bug-autoconf@gnu.org>."
 
 ac_cs_version="\\
 $CONFIG_STATUS generated by autoconf version AC_ACVERSION.
-Configured on host `(hostname || uname -n) 2>/dev/null | sed 1q` by running
-  [$]0 [$]ac_configure_args"
+Configured on host `(hostname || uname -n) 2>/dev/null | sed 1q` by
+  `echo "[$]0 [$]ac_configure_args" | sed 's/[[\\"\`\$]]/\\\\&/g'`"
 
 dnl We use a different name than CONFTEST just to help the maintainers
 dnl to make the difference between `conftest' which is the root of the
index 7b812803a89731b0ac91664dd34c30078cd96873..976b150aea921a11f81e80cdedc4cb563c4c2d38 100644 (file)
@@ -627,12 +627,7 @@ do
     continue
   fi
 
-  case "$ac_option" in
-changequote(, )dnl
-  -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
-changequote([, ])dnl
-  *) ac_optarg= ;;
-  esac
+[  ac_optarg=`echo "$ac_option" | sed -n 's/^[^=]*=//p'`]
 
   # Accept the important Cygnus configure options, so we can diagnose typos.
 
@@ -975,14 +970,15 @@ changequote([, ])dnl
     ;;
 
   *=*)
-    ac_envvar=`echo $ac_option|sed -e 's/=.*//'`
+    ac_envvar=`echo "$ac_option" | sed -e 's/=.*//'`
     # Reject names that are not valid shell variable names.
 changequote(, )dnl
-    if test -n "`echo $ac_envvar| sed 's/[_a-zA-Z0-9]//g'`"; then
+    if echo "$ac_envvar" | grep '[^a-zA-Z0-9_]' >/dev/null 2>&1; then
 changequote([, ])dnl
       AC_MSG_ERROR($ac_envvar: invalid variable name)
     fi
-    eval "${ac_envvar}='$ac_optarg'"
+    ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`
+    eval "$ac_envvar='$ac_optarg'"
     export $ac_envvar ;;
 
   *)
@@ -1097,8 +1093,8 @@ do
 changequote(<<, >>)dnl
 dnl If you change this globbing pattern, test it on an old shell --
 dnl it's sensitive.  Putting any kind of quote in it causes syntax errors.
-  *" "*|*"     "*|*[\[\]\~\<<#>>\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
-  ac_arg=`echo "$ac_arg"|sed "s/'/'\\\\\\\\''/g"`
+  *" "*|*"     "*|*[\[\]\~\<<#>>\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
+  ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"`
   ac_configure_args="$ac_configure_args '$ac_arg'" ;;
 changequote([, ])dnl
   *) ac_configure_args="$ac_configure_args $ac_arg" ;;
@@ -3387,8 +3383,8 @@ Report bugs to <bug-autoconf@gnu.org>."
 
 ac_cs_version="\\
 $CONFIG_STATUS generated by autoconf version AC_ACVERSION.
-Configured on host `(hostname || uname -n) 2>/dev/null | sed 1q` by running
-  [$]0 [$]ac_configure_args"
+Configured on host `(hostname || uname -n) 2>/dev/null | sed 1q` by
+  `echo "[$]0 [$]ac_configure_args" | sed 's/[[\\"\`\$]]/\\\\&/g'`"
 
 dnl We use a different name than CONFTEST just to help the maintainers
 dnl to make the difference between `conftest' which is the root of the
index 612d1f453a4b2cb8d0f4af173ff457af8beacccb..9d177aba581c4466a59c429a3befc7643081b821 100644 (file)
@@ -79,3 +79,41 @@ AT_DATA(expout,
 
 dnl Remove test files.
 rm -f dummy dummy.in
+
+
+
+dnl ## ------------------------------------------------------ ##
+dnl ## Check that `configure' and `config.status' honor their ##
+dnl ## interface.                                             ##
+dnl ## ------------------------------------------------------ ##
+
+dnl We run `./configure result=val' and verify that (i) `configure'
+dnl correctly receives `val' and (ii) correctly passes it to
+dnl `config.status', which we check by running `config.status
+dnl --recheck' (which *must* preserve the value of `result').
+
+AT_SETUP(command line interface)
+
+AT_DATA(configure.in,
+[[AC_INIT
+echo "result=$result"
+AC_OUTPUT
+]])
+
+AT_CHECK([../autoconf -m .. -l $at_srcdir], 0,, ignore)
+
+AT_CHECK([./configure result=result | sed -n -e 's/^result=//p'], 0,
+         [result
+], ignore)
+AT_CHECK([./config.status --recheck | sed -n -e 's/^result=//p'], 0,
+         [result
+], ignore)
+
+AT_CHECK([./configure result="\"'$" | sed -n -e 's/^result=//p'], 0,
+         ["'$
+], ignore)
+AT_CHECK([./config.status --recheck | sed -n -e 's/^result=//p'], 0,
+         ["'$
+], ignore)
+
+AT_CLEANUP(configure config.status config.log config.cache)