Skip to content

Commit

Permalink
Rename variable name in choice() for better semantics
Browse files Browse the repository at this point in the history
  • Loading branch information
andsens committed Aug 17, 2024
1 parent 29a7661 commit e8f7bbf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docopt_sh/docopt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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[@]}")
Expand Down

0 comments on commit e8f7bbf

Please sign in to comment.