autoconf: 1999-10-05 Andreas Schwab <schwab@issan.cs.uni-dortmund.de>

https://github.com/libsdl-org/autoconf/commit/91d8af658f0697a12cbf7bef1125b495904b5eb5

From 91d8af658f0697a12cbf7bef1125b495904b5eb5 Mon Sep 17 00:00:00 2001
From: Akim Demaille <[EMAIL REDACTED]>
Date: Tue, 5 Oct 1999 09:41:02 +0000
Subject: [PATCH] 1999-10-05  Andreas Schwab  <schwab@issan.cs.uni-dortmund.de>

	Shell meta characters in an argument causes the configure script
	to freak out and generate a config.status file that contains
	syntax errors.
	Bug triggered by ./configure --with-foobar=\''`"$'.

	* acgeneral.m4 (AC_INIT_PARSE_ARGS): Quote single quotes that end
	up between single quotes.  Protect arguments of echo with double
	quotes.
	(AC_INIT_PREPARE): Likewise.
	(AC_PATH_PROG): Protect argument of test.
	(AC_OUTPUT): Quote meta characters in ac_configure_args.
---
 ChangeLog               | 14 ++++++++++++++
 THANKS                  |  1 +
 acgeneral.m4            | 29 +++++++++++++++--------------
 lib/autoconf/general.m4 | 29 +++++++++++++++--------------
 4 files changed, 45 insertions(+), 28 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0f5ff15d..7a879d1f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+1999-10-05  Andreas Schwab  <schwab@issan.cs.uni-dortmund.de>
+
+	Shell meta characters in an argument causes the configure script
+	to freak out and generate a config.status file that contains
+	syntax errors.
+	Bug triggered by ./configure --with-foobar=\''`"$'.
+
+	* acgeneral.m4 (AC_INIT_PARSE_ARGS): Quote single quotes that end
+	up between single quotes.  Protect arguments of echo with double
+	quotes.
+	(AC_INIT_PREPARE): Likewise.
+	(AC_PATH_PROG): Protect argument of test.
+	(AC_OUTPUT): Quote meta characters in ac_configure_args.
+
 1999-10-05  Akim Demaille  <akim@epita.fr>
 
 	The sed quoting script depends on the shape of the commands used
diff --git a/THANKS b/THANKS
index 05f260b6..206baa36 100644
--- a/THANKS
+++ b/THANKS
@@ -27,6 +27,7 @@ Jim Blandy 		jimb@wookumz.gnu.ai.mit.edu
 Jim Meyering		meyering@ascend.com
 Karl Berry		karl@cs.umb.edu
 Kaveh R. Ghazi		ghazi@caip.rutgers.edu
+Ken Pizzini		ken@halcyon.com
 Matthew D. Langston	langston@SLAC.Stanford.EDU
 Mike Stump		mrs@wrs.com
 Miles Bader		miles@gnu.ai.mit.edu
diff --git a/acgeneral.m4 b/acgeneral.m4
index eb178f7d..21548d09 100644
--- a/acgeneral.m4
+++ b/acgeneral.m4
@@ -854,10 +854,10 @@ changequote([, ])dnl
     datadir="$ac_optarg" ;;
 
   -disable-* | --disable-*)
-    ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
+    ac_feature=`echo "$ac_option"|sed -e 's/-*disable-//'`
     # Reject names that are not valid shell variable names.
 changequote(, )dnl
-    if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
+    if test -n "`echo "$ac_feature"| sed 's/[-a-zA-Z0-9_]//g'`"; then
 changequote([, ])dnl
       AC_MSG_ERROR($ac_feature: invalid feature name)
     fi
@@ -865,16 +865,16 @@ changequote([, ])dnl
     eval "enable_${ac_feature}=no" ;;
 
   -enable-* | --enable-*)
-    ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
+    ac_feature=`echo "$ac_option"|sed -e 's/-*enable-//' -e 's/=.*//'`
     # Reject names that are not valid shell variable names.
 changequote(, )dnl
-    if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
+    if test -n "`echo "$ac_feature"| sed 's/[-_a-zA-Z0-9]//g'`"; then
 changequote([, ])dnl
       AC_MSG_ERROR($ac_feature: invalid feature name)
     fi
     ac_feature=`echo $ac_feature| sed 's/-/_/g'`
     case "$ac_option" in
-      *=*) ;;
+      *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
       *) ac_optarg=yes ;;
     esac
     eval "enable_${ac_feature}='$ac_optarg'" ;;
@@ -1118,25 +1118,25 @@ Some of the influent environment variables:$ac_arg_var_help"
     exit 0 ;;
 
   -with-* | --with-*)
-    ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
+    ac_package=`echo "$ac_option"|sed -e 's/-*with-//' -e 's/=.*//'`
     # Reject names that are not valid shell variable names.
 changequote(, )dnl
-    if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
+    if test -n "`echo "$ac_package"| sed 's/[-_a-zA-Z0-9]//g'`"; then
 changequote([, ])dnl
       AC_MSG_ERROR($ac_package: invalid package name)
     fi
     ac_package=`echo $ac_package| sed 's/-/_/g'`
     case "$ac_option" in
-      *=*) ;;
+      *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
       *) ac_optarg=yes ;;
     esac
     eval "with_${ac_package}='$ac_optarg'" ;;
 
   -without-* | --without-*)
-    ac_package=`echo $ac_option|sed -e 's/-*without-//'`
+    ac_package=`echo "$ac_option"|sed -e 's/-*without-//'`
     # Reject names that are not valid shell variable names.
 changequote(, )dnl
-    if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
+    if test -n "`echo "$ac_package"| sed 's/[-a-zA-Z0-9_]//g'`"; then
 changequote([, ])dnl
       AC_MSG_ERROR($ac_package: invalid package name)
     fi
@@ -1177,7 +1177,7 @@ changequote([, ])dnl
 
   *)
 changequote(, )dnl
-    if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
+    if test -n "`echo "$ac_option"| sed 's/[-a-z0-9.]//g'`"; then
 changequote([, ])dnl
       AC_MSG_WARN($ac_option: invalid host type)
     fi
@@ -1276,6 +1276,7 @@ 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_configure_args="$ac_configure_args '$ac_arg'" ;;
 changequote([, ])dnl
   *) ac_configure_args="$ac_configure_args $ac_arg" ;;
@@ -1307,7 +1308,7 @@ if test -z "$srcdir"; then
   # Try the directory containing this script, then its parent.
   ac_prog=[$]0
 changequote(, )dnl
-  ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
+  ac_confdir=`echo "$ac_prog"|sed 's%/[^/][^/]*$%%'`
 changequote([, ])dnl
   test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
   srcdir=$ac_confdir
@@ -2148,7 +2149,7 @@ dnl not every word.  This closes a longstanding sh security hole.
   ac_dummy="ifelse([$4], , $PATH, [$4])"
   for ac_dir in $ac_dummy; do
     test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$ac_word; then
+    if test -f "$ac_dir/$ac_word"; then
       ac_cv_path_$1="$ac_dir/$ac_word"
       break
     fi
@@ -2995,7 +2996,7 @@ for ac_option
 do
   case "[\$]ac_option" in
   -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
-    echo "running [\$]{CONFIG_SHELL-/bin/sh} [$]0 [$]ac_configure_args --no-create --no-recursion"
+    echo "running [\$]{CONFIG_SHELL-/bin/sh} [$]0 `echo "[$]ac_configure_args" | sed 's/[[\\"\`\$]]/\\\\&/g'` --no-create --no-recursion"
     exec [\$]{CONFIG_SHELL-/bin/sh} [$]0 [$]ac_configure_args --no-create --no-recursion ;;
   -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
     echo "[\$]ac_cs_version"; exit 0 ;;
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index eb178f7d..21548d09 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -854,10 +854,10 @@ changequote([, ])dnl
     datadir="$ac_optarg" ;;
 
   -disable-* | --disable-*)
-    ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
+    ac_feature=`echo "$ac_option"|sed -e 's/-*disable-//'`
     # Reject names that are not valid shell variable names.
 changequote(, )dnl
-    if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
+    if test -n "`echo "$ac_feature"| sed 's/[-a-zA-Z0-9_]//g'`"; then
 changequote([, ])dnl
       AC_MSG_ERROR($ac_feature: invalid feature name)
     fi
@@ -865,16 +865,16 @@ changequote([, ])dnl
     eval "enable_${ac_feature}=no" ;;
 
   -enable-* | --enable-*)
-    ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
+    ac_feature=`echo "$ac_option"|sed -e 's/-*enable-//' -e 's/=.*//'`
     # Reject names that are not valid shell variable names.
 changequote(, )dnl
-    if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
+    if test -n "`echo "$ac_feature"| sed 's/[-_a-zA-Z0-9]//g'`"; then
 changequote([, ])dnl
       AC_MSG_ERROR($ac_feature: invalid feature name)
     fi
     ac_feature=`echo $ac_feature| sed 's/-/_/g'`
     case "$ac_option" in
-      *=*) ;;
+      *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
       *) ac_optarg=yes ;;
     esac
     eval "enable_${ac_feature}='$ac_optarg'" ;;
@@ -1118,25 +1118,25 @@ Some of the influent environment variables:$ac_arg_var_help"
     exit 0 ;;
 
   -with-* | --with-*)
-    ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
+    ac_package=`echo "$ac_option"|sed -e 's/-*with-//' -e 's/=.*//'`
     # Reject names that are not valid shell variable names.
 changequote(, )dnl
-    if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
+    if test -n "`echo "$ac_package"| sed 's/[-_a-zA-Z0-9]//g'`"; then
 changequote([, ])dnl
       AC_MSG_ERROR($ac_package: invalid package name)
     fi
     ac_package=`echo $ac_package| sed 's/-/_/g'`
     case "$ac_option" in
-      *=*) ;;
+      *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
       *) ac_optarg=yes ;;
     esac
     eval "with_${ac_package}='$ac_optarg'" ;;
 
   -without-* | --without-*)
-    ac_package=`echo $ac_option|sed -e 's/-*without-//'`
+    ac_package=`echo "$ac_option"|sed -e 's/-*without-//'`
     # Reject names that are not valid shell variable names.
 changequote(, )dnl
-    if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
+    if test -n "`echo "$ac_package"| sed 's/[-a-zA-Z0-9_]//g'`"; then
 changequote([, ])dnl
       AC_MSG_ERROR($ac_package: invalid package name)
     fi
@@ -1177,7 +1177,7 @@ changequote([, ])dnl
 
   *)
 changequote(, )dnl
-    if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
+    if test -n "`echo "$ac_option"| sed 's/[-a-z0-9.]//g'`"; then
 changequote([, ])dnl
       AC_MSG_WARN($ac_option: invalid host type)
     fi
@@ -1276,6 +1276,7 @@ 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_configure_args="$ac_configure_args '$ac_arg'" ;;
 changequote([, ])dnl
   *) ac_configure_args="$ac_configure_args $ac_arg" ;;
@@ -1307,7 +1308,7 @@ if test -z "$srcdir"; then
   # Try the directory containing this script, then its parent.
   ac_prog=[$]0
 changequote(, )dnl
-  ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
+  ac_confdir=`echo "$ac_prog"|sed 's%/[^/][^/]*$%%'`
 changequote([, ])dnl
   test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
   srcdir=$ac_confdir
@@ -2148,7 +2149,7 @@ dnl not every word.  This closes a longstanding sh security hole.
   ac_dummy="ifelse([$4], , $PATH, [$4])"
   for ac_dir in $ac_dummy; do
     test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$ac_word; then
+    if test -f "$ac_dir/$ac_word"; then
       ac_cv_path_$1="$ac_dir/$ac_word"
       break
     fi
@@ -2995,7 +2996,7 @@ for ac_option
 do
   case "[\$]ac_option" in
   -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
-    echo "running [\$]{CONFIG_SHELL-/bin/sh} [$]0 [$]ac_configure_args --no-create --no-recursion"
+    echo "running [\$]{CONFIG_SHELL-/bin/sh} [$]0 `echo "[$]ac_configure_args" | sed 's/[[\\"\`\$]]/\\\\&/g'` --no-create --no-recursion"
     exec [\$]{CONFIG_SHELL-/bin/sh} [$]0 [$]ac_configure_args --no-create --no-recursion ;;
   -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
     echo "[\$]ac_cs_version"; exit 0 ;;