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.
This commit is contained in:
Akim Demaille 2000-02-09 18:24:24 +00:00
parent c60a188814
commit e1b31f306e
4 changed files with 70 additions and 26 deletions

View File

@ -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

View 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

View 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

View 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)