From c1c56730597cdf8b1269349d1d40a5a0f453a248 Mon Sep 17 00:00:00 2001 From: Yevgeniy Brikman Date: Wed, 18 May 2016 18:08:37 +0200 Subject: [PATCH] Fix how params are passed so we can handle spaces in param values --- gruntwork-install | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/gruntwork-install b/gruntwork-install index 61ff3ed..83901d7 100755 --- a/gruntwork-install +++ b/gruntwork-install @@ -97,32 +97,22 @@ function validate_module { fi } -# Take in an array of key-val pairs in this format: -# module_params[0] = "key1=value1" -# module_params[1] = "key2=value2" -# .. and convert it to the format that Gruntwork bash scripts expect: -# --key1 value1 --key2 value2 +# Take in a key-value pair of the format key=value and convert it to the format that Gruntwork bash scripts expect: +# --key value function convert_module_params_format { - local readonly module_params=("${@}") - - module_params_formatted="" - for key_val_expression in "${module_params[@]}"; do - key="${key_val_expression%=*}" - val="${key_val_expression#*=}" - module_params_formatted="--${key} ${val} ${module_params_formatted}" - done - - echo $module_params_formatted + local readonly key_value_pair="$1" + local readonly key="${key_value_pair%%=*}" + local readonly val="${key_value_pair#*=}" + echo "--${key} '${val}'" } function run_module { local readonly module_name="$1" shift - local readonly module_params=($@) - local readonly module_params_formatted=$(convert_module_params_format "${module_params[@]}") + local readonly module_params="$@" chmod -R u+x "${MODULES_DOWNLOAD_DIR}/${module_name}" - eval "${MODULES_DOWNLOAD_DIR}/${module_name}/${MODULE_INSTALL_FILE_NAME} ${module_params_formatted}" + ${MODULES_DOWNLOAD_DIR}/${module_name}/${MODULE_INSTALL_FILE_NAME} $module_params } function install_script_module { @@ -148,8 +138,8 @@ function install_script_module { shift ;; --module-param) - module_param="$2" - module_params+=("$module_param") + local readonly param=$(convert_module_params_format "$2") + module_params+=("$param") shift ;; --help)