The help output, which consists of the subcommand name and the
one-line description, is formatted incorrectly if the name of one
or more subcommands exceeds 16 characters. Pre-compute the maximal
length of the command names upfront to fix that.
y/\n/'"$tab"'/
# and print the sucker
- p'
+ p
+ ' | {
+ local -a cmds=() descs=()
+ local -i i maxlen=1
+ local cmd desc
+ while read cmd desc; do
+ ((maxlen < ${#cmd})) && maxlen=${#cmd}
+ cmds[${#cmds[@]}]=$cmd
+ descs[${#descs[@]}]=$desc
+ done
+ for ((i = 0; i < ${#cmds[@]}; i++)); do
+ printf '%-*s %s\n' $maxlen ${cmds[$i]} \
+ "${descs[$i]}"
+ done
+ }
printf "\n# Try %s help <command> for info on <command>, or %s help -a to see\n" \
"$gsu_name" "$gsu_name"
printf '# also the subcommands which are automatically generated by gsu.\n'