added getopt like error for missing option parameters
This commit is contained in:
parent
8f33d5549f
commit
b02c7c8fb5
8 changed files with 120 additions and 30 deletions
|
@ -105,6 +105,17 @@ Report bugs to <bug-grub@gnu.org>.
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
argument () {
|
||||||
|
opt=$1
|
||||||
|
shift
|
||||||
|
|
||||||
|
if test $# -eq 0; then
|
||||||
|
echo "$0: option requires an argument -- '$opt'" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo $1
|
||||||
|
}
|
||||||
|
|
||||||
# Check the arguments.
|
# Check the arguments.
|
||||||
while test $# -gt 0
|
while test $# -gt 0
|
||||||
do
|
do
|
||||||
|
@ -120,37 +131,37 @@ do
|
||||||
exit 0 ;;
|
exit 0 ;;
|
||||||
|
|
||||||
--modules)
|
--modules)
|
||||||
modules=$1; shift;;
|
modules=`argument $option "$@"`; shift;;
|
||||||
--modules=*)
|
--modules=*)
|
||||||
modules=`echo "$option" | sed 's/--modules=//'` ;;
|
modules=`echo "$option" | sed 's/--modules=//'` ;;
|
||||||
|
|
||||||
--font)
|
--font)
|
||||||
font=$1; shift;;
|
font=`argument $option "$@"`; shift;;
|
||||||
--font=*)
|
--font=*)
|
||||||
font=`echo "$option" | sed 's/--font=//'` ;;
|
font=`echo "$option" | sed 's/--font=//'` ;;
|
||||||
|
|
||||||
--root-directory)
|
--root-directory)
|
||||||
rootdir=$1; shift;;
|
rootdir=`argument $option "$@"`; shift;;
|
||||||
--root-directory=*)
|
--root-directory=*)
|
||||||
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
|
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
|
||||||
|
|
||||||
--grub-setup)
|
--grub-setup)
|
||||||
grub_setup=$1; shift;;
|
grub_setup=`argument $option "$@"`; shift;;
|
||||||
--grub-setup=*)
|
--grub-setup=*)
|
||||||
grub_setup=`echo "$option" | sed 's/--grub-setup=//'` ;;
|
grub_setup=`echo "$option" | sed 's/--grub-setup=//'` ;;
|
||||||
|
|
||||||
--grub-mkimage)
|
--grub-mkimage)
|
||||||
grub_mkimage=$1; shift;;
|
grub_mkimage=`argument $option "$@"`; shift;;
|
||||||
--grub-mkimage=*)
|
--grub-mkimage=*)
|
||||||
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
|
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
|
||||||
|
|
||||||
--grub-mkdevicemap)
|
--grub-mkdevicemap)
|
||||||
grub_mkdevicemap=$1; shift;;
|
grub_mkdevicemap=`argument $option "$@"`; shift;;
|
||||||
--grub-mkdevicemap=*)
|
--grub-mkdevicemap=*)
|
||||||
grub_mkdevicemap=`echo "$option" | sed 's/--grub-mkdevicemap=//'` ;;
|
grub_mkdevicemap=`echo "$option" | sed 's/--grub-mkdevicemap=//'` ;;
|
||||||
|
|
||||||
--grub-probe)
|
--grub-probe)
|
||||||
grub_probe=$1; shift;;
|
grub_probe=`argument $option "$@"`; shift;;
|
||||||
--grub-probe=*)
|
--grub-probe=*)
|
||||||
grub_probe=`echo "$option" | sed 's/--grub-probe=//'` ;;
|
grub_probe=`echo "$option" | sed 's/--grub-probe=//'` ;;
|
||||||
|
|
||||||
|
@ -161,7 +172,7 @@ do
|
||||||
|
|
||||||
--disk-module)
|
--disk-module)
|
||||||
if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
|
if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
|
||||||
disk_module=$1; shift;
|
disk_module=`argument $option "$@"`; shift;
|
||||||
fi ;;
|
fi ;;
|
||||||
--disk-module=*)
|
--disk-module=*)
|
||||||
if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
|
if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
|
||||||
|
|
|
@ -49,6 +49,17 @@ Report bugs to <bug-grub@gnu.org>.
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
argument () {
|
||||||
|
opt=$1
|
||||||
|
shift
|
||||||
|
|
||||||
|
if test $# -eq 0; then
|
||||||
|
echo "$0: option requires an argument -- '$opt'" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo $1
|
||||||
|
}
|
||||||
|
|
||||||
# Check the arguments.
|
# Check the arguments.
|
||||||
while test $# -gt 0
|
while test $# -gt 0
|
||||||
do
|
do
|
||||||
|
@ -63,9 +74,7 @@ do
|
||||||
echo "$0 (GNU GRUB ${package_version})"
|
echo "$0 (GNU GRUB ${package_version})"
|
||||||
exit 0 ;;
|
exit 0 ;;
|
||||||
-o | --output)
|
-o | --output)
|
||||||
grub_cfg=$1
|
grub_cfg=`argument $option "$@"`; shift;;
|
||||||
shift
|
|
||||||
;;
|
|
||||||
--output=*)
|
--output=*)
|
||||||
grub_cfg=`echo "$option" | sed 's/--output=//'`
|
grub_cfg=`echo "$option" | sed 's/--output=//'`
|
||||||
;;
|
;;
|
||||||
|
@ -74,6 +83,10 @@ do
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
*)
|
||||||
|
echo "Invalid parameter, $option" 1>&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,17 @@ Report bugs to <bug-grub@gnu.org>.
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
argument () {
|
||||||
|
opt=$1
|
||||||
|
shift
|
||||||
|
|
||||||
|
if test $# -eq 0; then
|
||||||
|
echo "$0: option requires an argument -- '$opt'" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo $1
|
||||||
|
}
|
||||||
|
|
||||||
# Check the arguments.
|
# Check the arguments.
|
||||||
while test $# -gt 0
|
while test $# -gt 0
|
||||||
do
|
do
|
||||||
|
@ -66,18 +77,18 @@ do
|
||||||
exit 0 ;;
|
exit 0 ;;
|
||||||
|
|
||||||
--modules)
|
--modules)
|
||||||
modules=$1; shift ;;
|
modules=`argument $option "$@"`; shift ;;
|
||||||
--modules=*)
|
--modules=*)
|
||||||
modules=`echo "$option" | sed 's/--modules=//'` ;;
|
modules=`echo "$option" | sed 's/--modules=//'` ;;
|
||||||
|
|
||||||
-o | --output)
|
-o | --output)
|
||||||
output_image=$1; shift ;;
|
output_image=`argument $option "$@"`; shift ;;
|
||||||
--output=*)
|
--output=*)
|
||||||
output_image=`echo "$option" | sed 's/--output=//'` ;;
|
output_image=`echo "$option" | sed 's/--output=//'` ;;
|
||||||
|
|
||||||
# Intentionally undocumented
|
# Intentionally undocumented
|
||||||
--override-directory)
|
--override-directory)
|
||||||
override_dir=$1
|
override_dir=`argument $option "$@"`
|
||||||
shift
|
shift
|
||||||
PATH=${override_dir}:$PATH
|
PATH=${override_dir}:$PATH
|
||||||
export PATH
|
export PATH
|
||||||
|
@ -93,7 +104,7 @@ do
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
source="${source} ${option}" ;;
|
source="${source} ${option} $@"; break ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,17 @@ Report bugs to <bug-grub@gnu.org>.
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
argument () {
|
||||||
|
opt=$1
|
||||||
|
shift
|
||||||
|
|
||||||
|
if test $# -eq 0; then
|
||||||
|
echo "$0: option requires an argument -- '$opt'" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo $1
|
||||||
|
}
|
||||||
|
|
||||||
# Check the arguments.
|
# Check the arguments.
|
||||||
while test $# -gt 0
|
while test $# -gt 0
|
||||||
do
|
do
|
||||||
|
@ -59,7 +70,7 @@ do
|
||||||
exit 0 ;;
|
exit 0 ;;
|
||||||
|
|
||||||
--root-directory)
|
--root-directory)
|
||||||
rootdir=$1; shift ;;
|
rootdir=`argument $option "$@"`; shift ;;
|
||||||
--root-directory=*)
|
--root-directory=*)
|
||||||
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
|
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,17 @@ Report bugs to <bug-grub@gnu.org>.
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
argument () {
|
||||||
|
opt=$1
|
||||||
|
shift
|
||||||
|
|
||||||
|
if test $# -eq 0; then
|
||||||
|
echo "$0: option requires an argument -- '$opt'" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo $1
|
||||||
|
}
|
||||||
|
|
||||||
# Check the arguments.
|
# Check the arguments.
|
||||||
while test $# -gt 0
|
while test $# -gt 0
|
||||||
do
|
do
|
||||||
|
@ -59,7 +70,7 @@ do
|
||||||
exit 0 ;;
|
exit 0 ;;
|
||||||
|
|
||||||
--root-directory)
|
--root-directory)
|
||||||
rootdir=$1; shift ;;
|
rootdir=`argument $option "$@"`; shift ;;
|
||||||
--root-directory=*)
|
--root-directory=*)
|
||||||
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
|
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,17 @@ Report bugs to <bug-grub@gnu.org>.
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
argument () {
|
||||||
|
opt=$1
|
||||||
|
shift
|
||||||
|
|
||||||
|
if test $# -eq 0; then
|
||||||
|
echo "$0: option requires an argument -- '$opt'" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo $1
|
||||||
|
}
|
||||||
|
|
||||||
# Check the arguments.
|
# Check the arguments.
|
||||||
while test $# -gt 0
|
while test $# -gt 0
|
||||||
do
|
do
|
||||||
|
@ -86,27 +97,27 @@ do
|
||||||
exit 0 ;;
|
exit 0 ;;
|
||||||
|
|
||||||
--modules)
|
--modules)
|
||||||
modules=$1; shift ;;
|
modules=`argument $option "$@"`; shift ;;
|
||||||
--modules=*)
|
--modules=*)
|
||||||
modules=`echo "$option" | sed 's/--modules=//'` ;;
|
modules=`echo "$option" | sed 's/--modules=//'` ;;
|
||||||
|
|
||||||
--root-directory)
|
--root-directory)
|
||||||
rootdir=$1; shift ;;
|
rootdir=`argument $option "$@"`; shift ;;
|
||||||
--root-directory=*)
|
--root-directory=*)
|
||||||
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
|
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
|
||||||
|
|
||||||
--grub-mkimage)
|
--grub-mkimage)
|
||||||
grub_mkimage=$1; shift ;;
|
grub_mkimage=`argument $option "$@"`; shift ;;
|
||||||
--grub-mkimage=*)
|
--grub-mkimage=*)
|
||||||
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
|
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
|
||||||
|
|
||||||
--grub-mkdevicemap)
|
--grub-mkdevicemap)
|
||||||
grub_mkdevicemap=$1; shift ;;
|
grub_mkdevicemap=`argument $option "$@"`; shift ;;
|
||||||
--grub-mkdevicemap=*)
|
--grub-mkdevicemap=*)
|
||||||
grub_mkdevicemap=`echo "$option" | sed 's/--grub-mkdevicemap=//'` ;;
|
grub_mkdevicemap=`echo "$option" | sed 's/--grub-mkdevicemap=//'` ;;
|
||||||
|
|
||||||
--grub-probe)
|
--grub-probe)
|
||||||
grub_probe=$1; shift ;;
|
grub_probe=`argument $option "$@"`; shift ;;
|
||||||
--grub-probe=*)
|
--grub-probe=*)
|
||||||
grub_probe=`echo "$option" | sed 's/--grub-probe=//'` ;;
|
grub_probe=`echo "$option" | sed 's/--grub-probe=//'` ;;
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,17 @@ Report bugs to <bug-grub@gnu.org>.
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
argument () {
|
||||||
|
opt=$1
|
||||||
|
shift
|
||||||
|
|
||||||
|
if test $# -eq 0; then
|
||||||
|
echo "$0: option requires an argument -- '$opt'" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo $1
|
||||||
|
}
|
||||||
|
|
||||||
# Check the arguments.
|
# Check the arguments.
|
||||||
while test $# -gt 0
|
while test $# -gt 0
|
||||||
do
|
do
|
||||||
|
@ -89,27 +100,27 @@ do
|
||||||
exit 0 ;;
|
exit 0 ;;
|
||||||
|
|
||||||
--modules)
|
--modules)
|
||||||
modules=$1; shift ;;
|
modules=`argument $option "$@"`; shift ;;
|
||||||
--modules=*)
|
--modules=*)
|
||||||
modules=`echo "$option" | sed 's/--modules=//'` ;;
|
modules=`echo "$option" | sed 's/--modules=//'` ;;
|
||||||
|
|
||||||
--root-directory)
|
--root-directory)
|
||||||
rootdir=$1; shift ;;
|
rootdir=`argument $option "$@"`; shift ;;
|
||||||
--root-directory=*)
|
--root-directory=*)
|
||||||
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
|
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
|
||||||
|
|
||||||
--grub-mkdevicemap)
|
--grub-mkdevicemap)
|
||||||
grub_mkdevicemap=$1; shift ;;
|
grub_mkdevicemap=`argument $option "$@"`; shift ;;
|
||||||
--grub-mkdevicemap=*)
|
--grub-mkdevicemap=*)
|
||||||
grub_mkdevicemap=`echo "$option" | sed 's/--grub-mkdevicemap=//'` ;;
|
grub_mkdevicemap=`echo "$option" | sed 's/--grub-mkdevicemap=//'` ;;
|
||||||
|
|
||||||
--grub-mkimage)
|
--grub-mkimage)
|
||||||
grub_mkimage=$1; shift ;;
|
grub_mkimage=`argument $option "$@"`; shift ;;
|
||||||
--grub-mkimage=*)
|
--grub-mkimage=*)
|
||||||
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
|
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
|
||||||
|
|
||||||
--grub-probe)
|
--grub-probe)
|
||||||
grub_probe=$1; shift ;;
|
grub_probe=`argument $option "$@"`; shift ;;
|
||||||
--grub-probe=*)
|
--grub-probe=*)
|
||||||
grub_probe=`echo "$option" | sed 's/--grub-probe=//'` ;;
|
grub_probe=`echo "$option" | sed 's/--grub-probe=//'` ;;
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,17 @@ Report bugs to <bug-grub@gnu.org>.
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
argument () {
|
||||||
|
opt=$1
|
||||||
|
shift
|
||||||
|
|
||||||
|
if test $# -eq 0; then
|
||||||
|
echo "$0: option requires an argument -- '$opt'" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo $1
|
||||||
|
}
|
||||||
|
|
||||||
input_dir=${pkglibdir}
|
input_dir=${pkglibdir}
|
||||||
|
|
||||||
# Check the arguments.
|
# Check the arguments.
|
||||||
|
@ -69,17 +80,17 @@ do
|
||||||
exit 0 ;;
|
exit 0 ;;
|
||||||
|
|
||||||
--modules)
|
--modules)
|
||||||
modules=$1; shift ;;
|
modules=`argument $option "$@"`; shift ;;
|
||||||
--modules=*)
|
--modules=*)
|
||||||
modules=`echo "$option" | sed 's/--modules=//'` ;;
|
modules=`echo "$option" | sed 's/--modules=//'` ;;
|
||||||
|
|
||||||
--pkglibdir)
|
--pkglibdir)
|
||||||
input_dir=$1; shift ;;
|
input_dir=`argument $option "$@"`; shift ;;
|
||||||
--pkglibdir=*)
|
--pkglibdir=*)
|
||||||
input_dir=`echo "$option" | sed 's/--pkglibdir=//'` ;;
|
input_dir=`echo "$option" | sed 's/--pkglibdir=//'` ;;
|
||||||
|
|
||||||
--grub-mkimage)
|
--grub-mkimage)
|
||||||
grub_mkimage=$1; shift ;;
|
grub_mkimage=`argument $option "$@"`; shift ;;
|
||||||
--grub-mkimage=*)
|
--grub-mkimage=*)
|
||||||
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
|
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue