Skip to content

Commit f159a15

Browse files
committed
[bugfix] Switched to pre-increment for ((++hits))
Post-increment returns 0 when hits=0 set -e treats it as falsy and triggers exit
1 parent 7bca42e commit f159a15

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

bash-args.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ function args:flag() {
3131
local scan; [[ -z "$short" ]] && scan="^--${long}$" || scan="^-${short}$|^--${long}$";
3232

3333
local hit hits=0;
34-
while args::capture hit "$scan"; do ((hits++)); done
34+
while args::capture hit "$scan"; do ((++hits)); done
3535

3636
# Bundle: also match within combined short flags (-vfs)
3737
if [[ "$bundle" == "true" && -n "$short" ]]; then
3838
local bscan="^-[^-]*${short}";
3939
local rest;
4040
while args::capture hit "$bscan"; do
41-
((hits++));
41+
((++hits));
4242
rest="${hit//$short/}"; rest="${rest#-}";
4343
TOKENS=(${rest:+-$rest} "${TOKENS[@]}");
4444
done

0 commit comments

Comments
 (0)