summaryrefslogtreecommitdiff
path: root/configure
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-12-10 19:08:51 -0500
committermidipix <writeonce@midipix.org>2018-12-10 19:22:46 -0500
commitc4ed3b2e5a3f6e4e5192c9a4a65d0451caf37820 (patch)
tree8692b935496796be438f3a1285e01781d3cf2ce1 /configure
parentaa8e3c510f79b885291fc3fdc6942d062e027ee3 (diff)
downloadsbpython2-c4ed3b2e5a3f6e4e5192c9a4a65d0451caf37820.tar.bz2
sbpython2-c4ed3b2e5a3f6e4e5192c9a4a65d0451caf37820.tar.xz
build system: configure: robustly support special characters in custom args.
Special thanks to Jonas 'Sortie' Termansen, author of the Sortix operating sys (https://sortix.org), for brainstorming about the best way to forward arguments containing special symbols or characters to a sourced (aka dot) shell script, as well as sharing single-quote tips and tricks.
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure36
1 files changed, 9 insertions, 27 deletions
diff --git a/configure b/configure
index 00f97fe..4b7fe01 100755
--- a/configure
+++ b/configure
@@ -48,24 +48,15 @@ init_vars()
mb_project_dir=$(cd "$(dirname $0)" ; pwd)
mb_pwd=`pwd`
+ mb_custom_cfgdefs_args=''
+ mb_custom_cfgdefs_space=''
+
if [ -z "$mb_config" ]; then
. $mb_project_dir/config.project || exit 2
else
. "$mb_config" || exit 2
fi
- if [ $mb_use_custom_cfgdefs = 'yes' ]; then
- mb_custom_cfgdefs_wrapper=$(mktemp)
-
- if [ -z $mb_custom_cfgdefs_wrapper ]; then
- error_msg "failed to create a temporary file."
- exit 2
- fi
-
- printf '. $mb_project_dir/project/config/cfgdefs.sh \\\n' \
- > $mb_custom_cfgdefs_wrapper
- fi
-
# project
mb_nickname=$NICKNAME
mb_source_dir=$SOURCE_DIR
@@ -602,7 +593,8 @@ config_copy()
config_custom()
{
if [ $mb_use_custom_cfgdefs = 'yes' ]; then
- . $mb_custom_cfgdefs_wrapper
+ eval . $mb_project_dir/project/config/cfgdefs.sh \
+ "$mb_custom_cfgdefs_args"
config_copy
fi
@@ -885,20 +877,10 @@ for arg ; do
*)
if [ $mb_use_custom_cfgdefs = 'yes' ]; then
- printf '\t' >> $mb_custom_cfgdefs_wrapper
-
- mb_first='yes'
-
- for mb_arg in $arg; do
- if [ $mb_first = 'yes' ]; then
- printf '%s' $mb_arg >> $mb_custom_cfgdefs_wrapper
- mb_first='no'
- else
- printf '\\ %s' $mb_arg >> $mb_custom_cfgdefs_wrapper
- fi
- done
-
- printf ' \\\n' >> $mb_custom_cfgdefs_wrapper
+ mb_escaped_arg=\'$(printf '%s\n' "$arg" | sed -e "s/'/'\\\\''/g")\'
+ mb_escaped_arg="$mb_custom_cfgdefs_space$mb_escaped_arg"
+ mb_custom_cfgdefs_args="$mb_custom_cfgdefs_args$mb_escaped_arg"
+ mb_custom_cfgdefs_space=' '
else
error_msg ${arg#}: "unsupported config argument."
exit 2