many bugfix, fixed getopt split

This commit is contained in:
2026-10-13 16:01:13 +02:00
parent b5be992d82
commit ba1e07744e
22 changed files with 478 additions and 125 deletions
+10
View File
@@ -119,6 +119,16 @@ brew install shellcheck
stdout, returning 0.
- Use `getopt` (not `getopts`) for option parsing — it handles long options and
`--` correctly.
Rebuild the arguments from its output with the `_getopt_split` helper
(`profile.d/args.sh`), never with `eval set --` or `xargs`:
```bash
PARSED=$(getopt -o hv --long help,verbose -n 'mycmd' -- "$@") || return 1
local -a _pargs=()
_getopt_split _pargs "$PARSED"
set -- "${_pargs[@]}"
```
To restore traps saved with `trap -p`, use `_trap_restore` (no `eval` either).
- Follow existing error-return conventions: 0 = success, 1 = usage error,
2 = bad options, 3 = missing dependency, 4+ = runtime failure.
- Prefix all local helper variables with a short unique prefix (e.g. `_taz_`)