autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Improve argument quoting in config.log and config.status


From: Daniel Colascione
Subject: [PATCH] Improve argument quoting in config.log and config.status
Date: Sun, 4 Mar 2018 13:44:54 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

This change uses a new quoting strategy for configure arguments reported in config.log and config.status --config: arguments containing only safe characters are left unquoted; otherwise, arguments are surrounded by single quotes.

Previously, the config.log file header didn't quote arguments at all, and config.status --config would emit single-quoted versions of all arguments even when the single quotes were superfluous.

commit b2b9ffd27970bf8db795c7c5ad99870922133b71
Author: Daniel Colascione <address@hidden>
Date:   Sun Mar 4 13:28:23 2018 -0800

    fix quoting

diff --git a/NEWS b/NEWS
index 7c165351..746266c4 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,9 @@ GNU Autoconf NEWS - User visible changes.

 * Noteworthy changes in release ?.? (????-??-??) [?]

+** config.log properly escapes arguments in the header comment;
+   config.status --config output is now quoted in a more readable fashion
+
 ** Configure scripts now support a '--runstatedir' option, which
    defaults to '${localstatedir}/run', and which can be used to place
    per-process temporary runtime files (such as pid files) into '/run'
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index 8a64b1de..5fde689b 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -1183,6 +1183,19 @@ fi])dnl
 m4_define([_AC_INIT_CONFIG_LOG],
 [m4_divert_text([INIT_PREPARE],
 [m4_define([AS_MESSAGE_LOG_FD], 5)dnl
+ac_configure_args_raw=
+for ac_arg
+do
+  case $ac_arg in
+  *\'*)
+    ac_arg=`AS_ECHO(["$ac_arg"]) | sed "s/'/'\\\\\\\\''/g"` ;;
+  esac
+  AS_VAR_APPEND([ac_configure_args_raw], [" '$ac_arg'"])
+done
+ac_safe_unquote="[[a-zA-Z0-9_=\/,-]]"
+ac_configure_args_raw=`dnl
+AS_ECHO(["${ac_configure_args_raw} "]) |dnl
+sed "s/'\($ac_safe_unquote$ac_safe_unquote*\)' /\1 /g; s/ $//"`
 cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
@@ -1191,7 +1204,7 @@ It was created by m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])dnl
 $as_me[]m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]), which was
 generated by m4_PACKAGE_STRING.  Invocation command line was

-  $ $[0] address@hidden
+  $ $[0]$ac_configure_args_raw

 _ACEOF
 exec AS_MESSAGE_LOG_FD>>config.log
diff --git a/lib/autoconf/status.m4 b/lib/autoconf/status.m4
index 30a8a60c..c7d0ad0e 100644
--- a/lib/autoconf/status.m4
+++ b/lib/autoconf/status.m4
@@ -1431,8 +1431,12 @@ m4_if(m4_index(m4_defn([AC_PACKAGE_NAME]), [GNU ]), [0], [
 General help using GNU software: <https://www.gnu.org/gethelp/>.])])"

 _ACEOF
+ac_cs_config=`dnl
+AS_ECHO(["${ac_configure_args} "]) |dnl
+sed --posix "s/'\($ac_safe_unquote$ac_safe_unquote*\)' /\1 /g; s/ $//"`
+ac_cs_config_escaped=`AS_ECHO(["$ac_cs_config"]) | sed "s/^ //; s/'/'\\\\\\\\''/g"`
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-ac_cs_config="`AS_ECHO(["$ac_configure_args"]) | sed 's/^ //; s/[[\\""\`\$]]/\\\\&/g'`"
+ac_cs_config='$ac_cs_config_escaped'
 ac_cs_version="\\
 m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.status[]dnl
 m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION])



reply via email to

[Prev in Thread] Current Thread [Next in Thread]