9 Commits

Author SHA1 Message Date
7342a05822 Make cmdarg_dump print out cmdarg_argv as well
Some checks failed
CI with JUnit Report / build-and-test (push) Has been cancelled
2026-01-19 15:55:44 -05:00
cd9594264a Merge remote-tracking branch 'zaneduffield/master'
Some checks failed
CI with JUnit Report / build-and-test (push) Has been cancelled
2026-01-18 12:26:25 -05:00
Zane Duffield
94f11c6f01 Simply copyright and author header components when empty 2026-01-14 12:27:32 +11:00
Zane Duffield
66563ad58a Add .shellcheckrc to silence lints 2026-01-14 11:54:19 +11:00
Zane Duffield
9772c9378d Fix misc shellcheck issues
* make clear that array expansion was not desired in one case
* change `$@` to `$*` in one case
* remove unnecessary `$` in arithmetic context
* fix quoting in complex traceback message
2026-01-14 11:54:19 +11:00
Zane Duffield
f649a18a75 Fix array expansion errors on unknown parameter names
When unexpected parameters are passed to cmdarg, the shell (bash 5.1.8)
spits out some error messages about bad array subscripts, for example

> cmdarg.sh: line 333: CMDARG_FLAGS: bad array subscript
> cmdarg.sh: line 334: CMDARG_FLAGS: bad array subscript
> cmdarg.sh: line 340: CMDARG: bad array subscript

This occurs because the array is being indexed by a null value, so to
prevent it we must guard all such uses with a check.
2026-01-14 11:54:19 +11:00
Zane Duffield
1e31ed1998 Quote array expansion when appending to cmdarg_argv
Without this change, excess arguments are split and glob-expanded when
appended to the cmdarg_argv array.
2026-01-14 11:54:19 +11:00
Zane Duffield
ad35f698ea Quote variables to avoid word splitting a glob matching
In all cases here, the contents of the variables are single words and do
not contain special glob characters, so it's mostly a change for
consistency and best practice.
2026-01-14 11:54:18 +11:00
Zane Duffield
8862ba1999 Convert tabs to spaces
The script used mixed indentation, meaning that it only made sense to
read when the tab width was set properly (to 8). Using consistent
indentation makes the script easier to read.
2026-01-14 11:13:40 +11:00

View File

@@ -412,6 +412,11 @@ function cmdarg_dump
echo "${repr} => ${cmdarg_cfg[$key]}"
fi
done
echo "argv =>"
for idx in "${!cmdarg_argv[@]}"
do
echo " ${idx} => ${cmdarg_argv[$idx]}"
done
}
function cmdarg_purge