Skip to content

Commit

Permalink
Merge pull request #2 from billyzkid/billyzkid-patch-2
Browse files Browse the repository at this point in the history
Fix default argument logic
  • Loading branch information
billyzkid authored Aug 24, 2023
2 parents 4af757a + d3d705e commit c4cffc7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/getopts_long.bash
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ getopts_long() {
shift 2

if [[ "${#}" == 0 ]]; then
local args=()
while [[ ${#BASH_ARGV[@]} -gt ${#args[@]} ]]; do
local index=$(( ${#BASH_ARGV[@]} - ${#args[@]} - 1 ))
args[${#args[@]}]="${BASH_ARGV[${index}]}"
local -i i
local -a args=()
for (( i = BASH_ARGC[0] + BASH_ARGC[1] - 1; i >= BASH_ARGC[0]; i-- )); do
args+=("${BASH_ARGV[i]}")
done
set -- "${args[@]}"
fi
Expand Down

0 comments on commit c4cffc7

Please sign in to comment.