From: Akim Demaille Date: Wed, 9 Feb 2000 18:24:24 +0000 (+0000) Subject: Fix the handling of `./configure foo=bar' and test it. X-Git-Tag: autoconf-2.50~1171 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e1b31f306ee6309d2796a73c70ea94e4e5f38a0f;p=thirdparty%2Fautoconf.git 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. --- diff --git a/ChangeLog b/ChangeLog index d22d1d3f3..bb08601f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2000-02-09 Akim Demaille + + 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 Resynchronize `INSTALL' with the current `configure', and diff --git a/acgeneral.m4 b/acgeneral.m4 index 7b812803a..976b150ae 100644 --- a/acgeneral.m4 +++ b/acgeneral.m4 @@ -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 ." 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 diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index 7b812803a..976b150ae 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -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 ." 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 diff --git a/tests/torture.m4 b/tests/torture.m4 index 612d1f453..9d177aba5 100644 --- a/tests/torture.m4 +++ b/tests/torture.m4 @@ -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)