3 ms·
I use it, both interactively and for scripts. One reason is that its `getopts` makes it very easy to provide full short and long option processing with help me
by kps 5y ago
I use it, both interactively and for scripts.
One reason is that its `getopts` makes it very easy to provide full short and long option processing with help messages; script boilerplate is something like
usage=$'
[-1]
[a:a-long-option?Help text]:[number]
[b:bool-long-option?Helpful text]
'
while getopts "$usage" c
do
typeset opt_$c="${OPTARG:-1}"
done
Another is that the final command of a pipeline runs in the shell environment, so that you can do things like
bunch |
of |
commands |
while read some stuff
do
RESULTS[$some]="$stuff"
done
and then use the $RESULTS. That is fairly painful in bash; basically you have to wrap the entire rest of the script in { … }.