From 7fcf9a4d5e0cc06e740127763a30abe28eba2370 Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Fri, 18 Aug 2023 14:35:28 +0700 Subject: [PATCH] fix(common): builder_parse broke on option parameters If you had an option with a parameter, e.g. "--outfile c,b", then the "c,b" was being treated as a parameter for expansion, which caused it to expand to e.g. "configure,build". Oops. --- resources/builder.inc.sh | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/resources/builder.inc.sh b/resources/builder.inc.sh index 6a47cbd529..d4d6bf7e2a 100755 --- a/resources/builder.inc.sh +++ b/resources/builder.inc.sh @@ -1183,7 +1183,21 @@ builder_parse() { fi if [[ $key =~ ^- ]]; then + + # Expand short -o to --option in options lookup + if [[ ! -z ${_builder_options_short[$key]+x} ]]; then + key=${_builder_options_short[$key]} + fi + exp+=($key) + if [[ ! -z ${_builder_options_var[$key]+x} ]]; then + shift + if [[ $# -eq 0 ]]; then + _builder_parameter_error "$0" parameter "$key" + fi + + exp+=("$1") + fi else # Expand comma separated values if [[ $key =~ : ]]; then @@ -1283,10 +1297,6 @@ _builder_parse_expanded_parameters() { fi n=$((n + 1)) - # Expand short -o to --option in options lookup - if [[ ! -z ${_builder_options_short[$key]+x} ]]; then - key=${_builder_options_short[$key]} - fi _builder_item_in_array "$key" "${_builder_options[@]}" && has_option=1 || has_option=0 if (( has_action )) && (( has_target )); then @@ -1315,9 +1325,6 @@ _builder_parse_expanded_parameters() { _builder_chosen_options+=("$key") if [[ ! -z ${_builder_options_var[$key]+x} ]]; then shift - if [[ $# -eq 0 ]]; then - _builder_parameter_error "$0" parameter "$key" - fi # Set the variable associated with this option to the next parameter value # A little bit of hoop jumping here to avoid issues with cygwin paths being # corrupted too early in the game