From e8f7bbf7f0fb3a23d00ba9f531953bcf57960f99 Mon Sep 17 00:00:00 2001 From: Anders Ingemann Date: Sat, 17 Aug 2024 19:34:41 +0200 Subject: [PATCH] Rename variable name in choice() for better semantics --- docopt_sh/docopt.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docopt_sh/docopt.sh b/docopt_sh/docopt.sh index d9dec77..22428cb 100644 --- a/docopt_sh/docopt.sh +++ b/docopt_sh/docopt.sh @@ -327,17 +327,17 @@ sequence() { } choice() { - local initial_params=("${params[@]}") best_match_idx match_count node_idx + local initial_params=("${params[@]}") best_match_idx unmatched_count node_idx # Increase testdepth so that we can test all subtrees without setting variables : $((testdepth++)) # Determine the best subtree match for node_idx in "$@"; do if "node_$node_idx"; then # Subtree matches - if [[ -z $match_count || ${#params[@]} -lt $match_count ]]; then + if [[ -z $unmatched_count || ${#params[@]} -lt $unmatched_count ]]; then # More params consumed than last iteration, best match so far best_match_idx=$node_idx - match_count=${#params[@]} + unmatched_count=${#params[@]} fi fi params=("${initial_params[@]}")