many bugfix, fixed getopt split
This commit is contained in:
@@ -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_`)
|
||||
|
||||
Reference in New Issue
Block a user