Fix --help formatting.
* util/grub-mkconfig_lib.in (print_option_help): New function. (grub_fmt): Likewise. * util/grub-install.in: Use print_option_help and grub_fmt. * util/grub-kbdcomp.in: Likewise. * util/grub-mkconfig.in: Likewise. * util/grub-mknetdir.in: Likewise. * util/grub-mkrescue.in: Likewise. * util/grub-mkstandalone.in: Likewise. * util/grub-reboot.in: Likewise. * util/grub-set-default.in: Likewise. * util/powerpc/ieee1275/grub-mkrescue.in: Likewise.
This commit is contained in:
parent
561ec77e2d
commit
9f9d3f69f4
11 changed files with 136 additions and 59 deletions
|
@ -286,3 +286,65 @@ uses_abstraction () {
|
|||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
print_option_help () {
|
||||
if test x$print_option_help_wc = x; then
|
||||
if wc -L < /dev/null > /dev/null; then
|
||||
print_option_help_wc=-L
|
||||
elif wc -m < /dev/null > /dev/null; then
|
||||
print_option_help_wc=-m
|
||||
else
|
||||
print_option_help_wc=-b
|
||||
fi
|
||||
fi
|
||||
if test x$grub_have_fmt = x; then
|
||||
if fmt -w 40 < /dev/null > /dev/null; then
|
||||
grub_have_fmt=y;
|
||||
else
|
||||
grub_have_fmt=n;
|
||||
fi
|
||||
fi
|
||||
print_option_help_lead=" $1"
|
||||
print_option_help_lspace="$(echo "$print_option_help_lead" | wc $print_option_help_wc)"
|
||||
print_option_help_fill="$((26 - print_option_help_lspace))"
|
||||
echo -n "$print_option_help_lead"
|
||||
if test $print_option_help_fill -le 0; then
|
||||
print_option_help_nl=y
|
||||
echo
|
||||
else
|
||||
print_option_help_i=0;
|
||||
while test $print_option_help_i -lt $print_option_help_fill; do
|
||||
echo -n " "
|
||||
print_option_help_i=$((print_option_help_i+1))
|
||||
done
|
||||
print_option_help_nl=n
|
||||
fi
|
||||
if test x$grub_have_fmt = xy; then
|
||||
print_option_help_split="$(echo "$2" | fmt -w 50)"
|
||||
else
|
||||
print_option_help_split="$2"
|
||||
fi
|
||||
if test x$print_option_help_nl = xy; then
|
||||
echo "$print_option_help_split" | awk \
|
||||
'{ print " " $0; }'
|
||||
else
|
||||
echo "$print_option_help_split" | awk 'BEGIN { n = 0 }
|
||||
{ if (n == 1) print " " $0; else print $0; n = 1 ; }'
|
||||
fi
|
||||
}
|
||||
|
||||
grub_fmt () {
|
||||
if test x$grub_have_fmt = x; then
|
||||
if fmt -w 40 < /dev/null > /dev/null; then
|
||||
grub_have_fmt=y;
|
||||
else
|
||||
grub_have_fmt=n;
|
||||
fi
|
||||
fi
|
||||
|
||||
if test x$grub_have_fmt = xy; then
|
||||
fmt
|
||||
else
|
||||
cat
|
||||
fi
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue