by djha-skin · 3y ago · 0 comments
arg=default
while [ -n "${1}" ]
do
case "${1}" in
--arg)
shift
arg="${1}"
shift
;;
*)
print_help_page
shift
;;
esac
done
The above is terse, readable, and doesn't rely on any dependencies other than POSIX compatibility.Often the whole point of shell scripts is that they're dependency free; nothing is needed other than the shell. After all, why code rustup in sh if not for this reason?
People who make libraries like this for shell are, I think, missing the point of shell.
arg=
while [[ "$#" -gt 0 ]]; do
case "$1" in
--arg) shift; arg="$1" ;;
*) help; exit 1 ;;
esac
shift
doneThe biggest issue I see with this is the generated code is a minified chunk of noise that can't be easily edited by hand by downstream users