update-grub --help options
PATCH 1/1 update-grub --help options
Hello,
I've noticed that update-grub doesn't handle usual options (especially -h and --help).
Here's a patch that fix it.
(it also remove a blank space in #!/bin/sh header)
Franklin
update-grub.new renamed from update-grub.orig +45 -6
@@ -1,5 +1,4 @@ -#! /bin/sh -e - +#!/bin/sh -e # Generate grub.cfg by inspecting /boot contents. # Copyright (C) 2006,2007,2008 Free Software Foundation, Inc. #
@@ -22,6 +21,9 @@ exec_prefix=@exec_prefix@ sbindir=@sbindir@ libdir=@libdir@ +PACKAGE_NAME=@PACKAGE_NAME@ +PACKAGE_TARNAME=@PACKAGE_TARNAME@ +PACKAGE_VERSION=@PACKAGE_VERSION@ sysconfdir=@sysconfdir@ grub_prefix=`echo /boot/grub | sed ${transform}` grub_cfg=${grub_prefix}/grub.cfg
@@ -34,6 +36,47 @@ # for convert_system_path_to_grub_path(), font_path() . ${libdir}/grub/update-grub_lib +# Usage: usage +# Print the usage. +usage () { + cat <<EOF +Usage: update-grub [OPTION] +Generate grub.cfg by inspecting /boot contents + + -h, --help print this message and exit + -v, --version print the version information and exit + -y an old option. Ignored for compatibility + +update-grub generates grub.cfg, according to preferences in /etc/default/grub +and by inspecting /boot contents. + +Report bugs to <[email protected]>. +EOF +} + +# Check the arguments. +for option in "$@"; do + case "$option" in + -h | --help) + usage + exit 0 ;; + -v | --version) + echo "update-grub (GNU GRUB ${PACKAGE_VERSION})" + exit 0 ;; + -y) + echo "$0: warning: Ignoring -y option (no longer needed)." >&2 + -*) + echo "$0: warning: Unrecognized option \`$option'" 1>&2 + usage + exit 1 + ;; + *) + echo "$0: warning: Unexpected argument \`$option'" 1>&2 + usage + exit 1 + esac +done + if [ "x$UID" = "x" ] ; then UID=`id -u` fi
@@ -43,10 +86,6 @@ exit 1 fi -if [ "$1" = "-y" ] ; then - echo "$0: warning: Ignoring -y option (no longer needed)." >&2 -fi - set $grub_mkdevicemap dummy if test -f "$1"; then :