40 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
Zane Duffield
94f11c6f01 Simply copyright and author header components when empty 2026-01-14 12:27:32 +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
John Axel Eriksson
5c2fbc5110 cmdarg_info so it checks for anything NOT in flags
The cmdarg_info function should check whether the input is NOT in flags rather than the other way around. Otherwise it will fail every time when doing one is actually doing the right thing.
2014-08-12 14:48:08 +02:00
aede1cefbe Fixed some broken longopt and helpers related tests 2014-06-07 22:39:58 -07:00
77bf69ee69 Fixes #6 : Proper array bounds checking 2014-06-07 21:38:03 -07:00
c7c2e31b83 Close #9 : Ensured all local vars are declared local. Also removed builtin cmdarg_cfg['cfgfile'] loading as it was undocumented and even I forgot it was there. 2014-05-26 12:26:18 -07:00
7188ec557f Close #5 : Removed all calls to cut/grep 2014-05-26 12:19:00 -07:00
d3721faf10 Close #17 and Close #16
Introduces CMDARG_ERROR_BEHAVIOR. Adds some more tests. Introduces new
behavior for hash validators (see README). Fixes a few odds and ends.
2014-05-26 11:45:17 -07:00
b7f85914e7 Close #13 : cmdarg_helpers[] introduced, README documentation updated 2014-05-20 08:49:46 -07:00
83c4552371 Made validators less silly (require strict functions) and updated docs 2014-05-19 17:15:54 -07:00
15ed92d390 Close #11 : This does, indeed, fix the big janky naming bug 2014-05-19 16:30:07 -07:00
1ba6694330 Close #7 : use BASH_VERSINFO instead of janky version check 2014-05-12 07:19:45 -07:00
f72240fd19 Closes #12 : all calls to cmdarg_usage go to stderr 2014-05-12 07:15:59 -07:00
071f170b67 Fixes #4 : Make cmdarg understand '--option=value|-o=value' syntax. 2014-04-19 21:41:57 -07:00
3b7f95e33e #3 : Fix handling of optional vs required arguments 2014-01-30 16:34:49 -05:00
d7e111c6d6 Fixes #1 : Long arguments now display in cmdarg_usage() 2014-01-27 11:22:14 -05:00
fa34368592 Fixed a bug where cmdarg_argv is not populated without -- 2014-01-09 10:34:47 -05:00
77698f430c Added long opt parsing, now understands -- and parses non-option elements into cmdarg_argv. Docs updated. 2013-11-13 11:14:09 -08:00
f95d181b6d Remove the c-style "have I been included before" check, because it actually was making things worse 2013-11-06 15:21:40 -05:00
16548e463b Added test to cover the case when cmdarg_purge erases or otherwise makes the cmdarg_cfg internals unusable, also changed the purge method to something much simpler 2013-11-01 14:16:59 -04:00
f9e71bffe3 Seriously... 2013-10-29 19:43:35 -04:00
c499425869 Fixed the exporting of cmdarg_ and CMDARG_ variables for subshells (for real this time) 2013-10-29 19:29:59 -04:00
08bc5c4c62 Syntax fix to previous fix (the people who sacked the previous people, have been sacked) 2013-10-29 19:11:01 -04:00
5facea1cc5 Fixed a bug where the #include fakery caused chained scripts that wanted to call cmdarg were unable to do so and were unable to see CMDARG_ associative arrays, so wierd things started happening 2013-10-29 19:10:08 -04:00
51b3114748 Fixed a bogus bash version check that caused cmdarg to refuse to run on systems with nonstandard bash 2013-10-16 00:43:20 -04:00
77d48c3425 Fixed PREFIX in Makefile, added several tests in tests/ 2013-10-09 22:42:16 -04:00
034e79e9bf Fixed the stupid cmdarg_* prefixing of hash and array arguments, just use the key 2013-10-09 13:38:06 -04:00
308e38279f Added a few new functions for dumping config state, also added new facilities for specifying that certain config options should be an array or a hash 2013-10-09 13:27:05 -04:00
299377270e Closes #2 : Add -o to fix a broken grep on the bash version in cygwin 2013-10-08 14:16:38 -04:00
baf7232c79 Added makefile and spec for rpm builds 2013-09-24 11:42:10 -04:00
cc6ba88784 Fixed a bug in how true/false flags are handled 2013-07-10 13:44:46 -04:00
a049ad7921 cmdarg_traceback prints LASTERR now 2013-07-09 09:20:33 -04:00
e10acfbd05 Added traceback function from http://blog.yjl.im/2012/01/printing-out-call-stack-in-bash.html 2013-07-09 06:59:42 -04:00
c3fe169bdd Initial commit, everything appears to work 2013-07-02 10:10:09 -04:00
6d247993f4 Initial commit, everything appears to work 2013-07-02 10:02:51 -04:00