From 917c483a2976db21334425d87a33d45ba8c58d60 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 22 Aug 2013 10:35:00 -0700 Subject: [PATCH] * configure.ac (EMACS_CONFIG_OPTIONS): Quote systematically. This improves on the patch already installed, by quoting options that contain spaces and suchlike systematically, so that EMACS_CONFIG_OPTIONS is no longer ambiguous when options contain these characters. Fixes: debbugs:13274 --- ChangeLog | 8 ++++++++ configure.ac | 47 +++++++++++++++++++++++++++++++++++------------ 2 files changed, 43 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 161069800a4..35dbeb6065c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2013-08-22 Paul Eggert + + * configure.ac (EMACS_CONFIG_OPTIONS): Quote systematically (Bug#13274). + This improves on the patch already installed, by quoting options + that contain spaces and suchlike systematically, so that + EMACS_CONFIG_OPTIONS is no longer ambiguous when options contain + these characters. + 2013-08-21 Paul Eggert Port close-on-exec pty creation to FreeBSD 9.1-RELEASE (Bug#15129). diff --git a/configure.ac b/configure.ac index 793267b6ccb..5737ec20abf 100644 --- a/configure.ac +++ b/configure.ac @@ -24,18 +24,43 @@ dnl along with GNU Emacs. If not, see . AC_PREREQ(2.65) AC_INIT(emacs, 24.3.50) +dnl Set emacs_config_options to the options of 'configure', quoted for the shell, +dnl and then quoted again for a C string. Separate options with spaces. +dnl Add some environment variables, if they were passed via the environment +dnl rather than on the command-line. +emacs_config_options= +optsep= dnl This is the documented way to record the args passed to configure, dnl rather than $ac_configure_args. -emacs_config_options="$@" -## Add some environment variables, if they were passed via the environment -## rather than on the command-line. -for var in CFLAGS CPPFLAGS LDFLAGS; do - case "$emacs_config_options" in - *$var=*) continue ;; - esac - eval val="\$${var}" - test x"$val" = x && continue - emacs_config_options="${emacs_config_options}${emacs_config_options:+ }$var=\"$val\"" +for opt in ${1+"$@"} CFLAGS CPPFLAGS LDFLAGS; do + case $opt in + -n | --no-create | --no-recursion) + continue ;; + CFLAGS | CPPFLAGS | LDFLAGS) + eval 'test "${'$opt'+set}" = set' || continue + case " $*" in + *" $opt="*) continue ;; + esac + eval opt=$opt=\$$opt ;; + esac + + emacs_shell_specials=$IFS\''"#$&()*;<>?@<:@\\`{|~' + case $opt in + *[["$emacs_shell_specials"]]*) + case $opt in + *\'*) + emacs_quote_apostrophes="s/'/'\\\\''/g" + opt=`AS_ECHO(["$opt"]) | sed "$emacs_quote_apostrophes"` ;; + esac + opt="'$opt'" + case $opt in + *[['"\\']]*) + emacs_quote_for_c='s/[["\\]]/\\&/g; $!s/$/\\n\\/' + opt=`AS_ECHO(["$opt"]) | sed "$emacs_quote_for_c"` ;; + esac ;; + esac + AS_VAR_APPEND([emacs_config_options], ["$optsep$opt"]) + optsep=' ' done AC_CONFIG_HEADER(src/config.h:src/config.in) @@ -4440,8 +4465,6 @@ fi AC_DEFINE_UNQUOTED(EMACS_CONFIGURATION, "${canonical}", [Define to the canonical Emacs configuration name.]) -dnl Replace any embedded " characters (bug#13274). -emacs_config_options=`echo "$emacs_config_options " | sed -e 's/--no-create //' -e 's/--no-recursion //' -e 's/ *$//' -e "s/\"/'/g" -e 's/\\\\/\\\\\\\\/g'` AC_DEFINE_UNQUOTED(EMACS_CONFIG_OPTIONS, "${emacs_config_options}", [Define to the options passed to configure.]) AH_TEMPLATE(config_opsysfile, [Some platforms that do not use configure -- 2.39.2