From f7b694183157b674abf68df1b830cadd93e18cdd Mon Sep 17 00:00:00 2001 From: Kaz Kyheku Date: Wed, 29 Jan 2020 22:13:25 -0800 Subject: build: drop config.log in favor of reconfigure The configure command line is now turned into an executable script called reconfigure which can be invoked to repeat the config. * Makefile (distclean): Whether in a configured or state or not, try to remove reconfigure. In the configured state, don't remove config.log. (If distclean is invoked when not configured, the config.* pattern will remove config.log). * configure: rewrite the logic which turns the command line into text. It is now robust against spaces, quotes and meta-charaters. Moreover, the printed representation is chosen according to good heuristics to minimize unnecessary quoting and escaping. The config line is written into an executable script called reconfigure. This is now done twice; it is done immediately, so that we save the command line even if the configure subsequently fails. A comment is added to reconfigure indicating that configure didn't succeed. Then after a successful run through the tests, we save it again, without the cautionary comment. Help texts updated. --- configure | 51 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 10 deletions(-) (limited to 'configure') diff --git a/configure b/configure index fcfe51c8..e2ad6ccd 100755 --- a/configure +++ b/configure @@ -52,23 +52,46 @@ set -u # # Save command line in a way that can be re-run. -# This takes care of spaces, but if there are shell-meta characters -# in the arguments, oops. # cmdline= for arg in "$0" ${@+"$@"} ; do [ -n "$cmdline" ] && cmdline="$cmdline " case $arg in - *" "* | " "* | *" " ) - cmdline=$cmdline$(printf "\"%s\"" "$arg") + *"'"* ) + case $arg in + *'"'* | *'$'* ) + cmdline="$cmdline'$(printf "%s" "$arg" | sed -e "s/'/'\\\\''/g")'" + ;; + * ) + cmdline="$cmdline\"$arg\"" + ;; + esac + ;; + *'"'* | *['$*?[']* | '~'* ) + cmdline="$cmdline'$arg'" ;; * ) - cmdline=$cmdline$arg + cmdline="$cmdline$arg" ;; esac done +# +# Tentatively save configuration in config.log +# +cat > reconfigure < config.log < reconfigure <