]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
added getopt like error for missing option parameters
authorBVK Chaitanya <bvk.groups@gmail.com>
Mon, 12 Apr 2010 16:03:03 +0000 (21:33 +0530)
committerBVK Chaitanya <bvk.groups@gmail.com>
Mon, 12 Apr 2010 16:03:03 +0000 (21:33 +0530)
util/grub-install.in
util/grub-mkconfig.in
util/grub-mkrescue.in
util/grub-reboot.in
util/grub-set-default.in
util/i386/efi/grub-install.in
util/ieee1275/grub-install.in
util/powerpc/ieee1275/grub-mkrescue.in

index 7b9c049132421dfb1b2fed3b9f0737518887097a..e5ed9dcd58be6b38025034952a7bf9d0c6c7ea36 100644 (file)
@@ -105,6 +105,17 @@ Report bugs to <bug-grub@gnu.org>.
 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.
 while test $# -gt 0
 do
@@ -120,37 +131,37 @@ do
        exit 0 ;;
 
     --modules)
-       modules=$1; shift;;
+       modules=`argument $option "$@"`; shift;;
     --modules=*)
        modules=`echo "$option" | sed 's/--modules=//'` ;;
 
     --font)
-       font=$1; shift;;
+       font=`argument $option "$@"`; shift;;
     --font=*)
        font=`echo "$option" | sed 's/--font=//'` ;;
 
     --root-directory)
-       rootdir=$1; shift;;
+       rootdir=`argument $option "$@"`; shift;;
     --root-directory=*)
        rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
 
     --grub-setup)
-       grub_setup=$1; shift;;
+       grub_setup=`argument $option "$@"`; shift;;
     --grub-setup=*)
        grub_setup=`echo "$option" | sed 's/--grub-setup=//'` ;;
 
     --grub-mkimage)
-       grub_mkimage=$1; shift;;
+       grub_mkimage=`argument $option "$@"`; shift;;
     --grub-mkimage=*)
        grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
 
     --grub-mkdevicemap)
-       grub_mkdevicemap=$1; shift;;
+       grub_mkdevicemap=`argument $option "$@"`; shift;;
     --grub-mkdevicemap=*)
        grub_mkdevicemap=`echo "$option" | sed 's/--grub-mkdevicemap=//'` ;;
 
     --grub-probe)
-       grub_probe=$1; shift;;
+       grub_probe=`argument $option "$@"`; shift;;
     --grub-probe=*)
        grub_probe=`echo "$option" | sed 's/--grub-probe=//'` ;;
 
@@ -161,7 +172,7 @@ do
 
     --disk-module)
        if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
-           disk_module=$1; shift;
+           disk_module=`argument $option "$@"`; shift;
        fi ;;
     --disk-module=*)
        if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
index 82964836b8df1b455b58151242708e06516f8f93..c3aa577233c62170ed30ca2e179b57a6d4e9e5cb 100644 (file)
@@ -49,6 +49,17 @@ Report bugs to <bug-grub@gnu.org>.
 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.
 while test $# -gt 0
 do
@@ -63,9 +74,7 @@ do
        echo "$0 (GNU GRUB ${package_version})"
        exit 0 ;;
     -o | --output)
-       grub_cfg=$1
-       shift
-       ;;
+       grub_cfg=`argument $option "$@"`; shift;;
     --output=*)
        grub_cfg=`echo "$option" | sed 's/--output=//'`
        ;;
@@ -74,6 +83,10 @@ do
        usage
        exit 1
        ;;
+    *)
+       echo "Invalid parameter, $option" 1>&2
+       exit 1
+       ;;
     esac
 done
 
index 64ccd6ae8de1bed92853f8fb5384a905f0339d02..ffb9877183beec7a48d4839b521f66f1722218fa 100644 (file)
@@ -51,6 +51,17 @@ Report bugs to <bug-grub@gnu.org>.
 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.
 while test $# -gt 0
 do
@@ -66,18 +77,18 @@ do
        exit 0 ;;
 
     --modules)
-        modules=$1; shift ;;
+        modules=`argument $option "$@"`; shift ;;
     --modules=*)
        modules=`echo "$option" | sed 's/--modules=//'` ;;
 
     -o | --output)
-       output_image=$1; shift ;;
+       output_image=`argument $option "$@"`; shift ;;
     --output=*)
        output_image=`echo "$option" | sed 's/--output=//'` ;;
 
     # Intentionally undocumented
     --override-directory)
-        override_dir=$1
+        override_dir=`argument $option "$@"`
        shift
        PATH=${override_dir}:$PATH
        export PATH
@@ -93,7 +104,7 @@ do
        exit 1
        ;;
     *)
-       source="${source} ${option}" ;;
+       source="${source} ${option} $@"; break ;;
     esac
 done
 
index eb7073e02b239c4ed81f9ac6a7b9a0eff44d6bc8..48e3ae24357e01d31cb912e464fc7e9f24261bfd 100644 (file)
@@ -44,6 +44,17 @@ Report bugs to <bug-grub@gnu.org>.
 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.
 while test $# -gt 0
 do
@@ -59,7 +70,7 @@ do
        exit 0 ;;
 
     --root-directory)
-       rootdir=$1; shift ;;
+       rootdir=`argument $option "$@"`; shift ;;
     --root-directory=*)
        rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
 
index 2636543c3843b70622d07629ef0d31e1bc380a40..a4739f95f1d4b92232e08329e0b76213b82f6d67 100644 (file)
@@ -44,6 +44,17 @@ Report bugs to <bug-grub@gnu.org>.
 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.
 while test $# -gt 0
 do
@@ -59,7 +70,7 @@ do
        exit 0 ;;
 
     --root-directory)
-       rootdir=$1; shift ;;
+       rootdir=`argument $option "$@"`; shift ;;
     --root-directory=*)
        rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
 
index 097519d500c2c9764d02edb16debc702f803de32..54c1906784c9f7e3b0585ea9bcf9939652453ef1 100644 (file)
@@ -71,6 +71,17 @@ Report bugs to <bug-grub@gnu.org>.
 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.
 while test $# -gt 0
 do
@@ -86,27 +97,27 @@ do
        exit 0 ;;
 
     --modules)
-        modules=$1; shift ;;
+        modules=`argument $option "$@"`; shift ;;
     --modules=*)
        modules=`echo "$option" | sed 's/--modules=//'` ;;
 
     --root-directory)
-       rootdir=$1; shift ;;
+       rootdir=`argument $option "$@"`; shift ;;
     --root-directory=*)
        rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
 
     --grub-mkimage)
-       grub_mkimage=$1; shift ;;
+       grub_mkimage=`argument $option "$@"`; shift ;;
     --grub-mkimage=*)
        grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
 
     --grub-mkdevicemap)
-       grub_mkdevicemap=$1; shift ;;
+       grub_mkdevicemap=`argument $option "$@"`; shift ;;
     --grub-mkdevicemap=*)
        grub_mkdevicemap=`echo "$option" | sed 's/--grub-mkdevicemap=//'` ;;
 
     --grub-probe)
-       grub_probe=$1; shift ;;
+       grub_probe=`argument $option "$@"`; shift ;;
     --grub-probe=*)
        grub_probe=`echo "$option" | sed 's/--grub-probe=//'` ;;
 
index 4a5403c18ce505287cf9f62762c1a0c8b4c77884..dde275c2a09b9703012e93bcf8cfda9da0a9302d 100644 (file)
@@ -74,6 +74,17 @@ Report bugs to <bug-grub@gnu.org>.
 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.
 while test $# -gt 0
 do
@@ -89,27 +100,27 @@ do
        exit 0 ;;
 
     --modules)
-       modules=$1; shift ;;
+       modules=`argument $option "$@"`; shift ;;
     --modules=*)
        modules=`echo "$option" | sed 's/--modules=//'` ;;
 
     --root-directory)
-       rootdir=$1; shift ;;
+       rootdir=`argument $option "$@"`; shift ;;
     --root-directory=*)
        rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
 
     --grub-mkdevicemap)
-       grub_mkdevicemap=$1; shift ;;
+       grub_mkdevicemap=`argument $option "$@"`; shift ;;
     --grub-mkdevicemap=*)
        grub_mkdevicemap=`echo "$option" | sed 's/--grub-mkdevicemap=//'` ;;
 
     --grub-mkimage)
-       grub_mkimage=$1; shift ;;
+       grub_mkimage=`argument $option "$@"`; shift ;;
     --grub-mkimage=*)
        grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
 
     --grub-probe)
-       grub_probe=$1; shift ;;
+       grub_probe=`argument $option "$@"`; shift ;;
     --grub-probe=*)
        grub_probe=`echo "$option" | sed 's/--grub-probe=//'` ;;
 
index 375adb0cb2098d70fba69ea423ffd30c3cad2d94..1adc149ae7d05d6f729b61756ee574bb03c10a54 100644 (file)
@@ -52,6 +52,17 @@ Report bugs to <bug-grub@gnu.org>.
 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}
 
 # Check the arguments.
@@ -69,17 +80,17 @@ do
        exit 0 ;;
 
     --modules)
-       modules=$1; shift ;;
+       modules=`argument $option "$@"`; shift ;;
     --modules=*)
        modules=`echo "$option" | sed 's/--modules=//'` ;;
 
     --pkglibdir)
-       input_dir=$1; shift ;;
+       input_dir=`argument $option "$@"`; shift ;;
     --pkglibdir=*)
        input_dir=`echo "$option" | sed 's/--pkglibdir=//'` ;;
 
     --grub-mkimage)
-       grub_mkimage=$1; shift ;;
+       grub_mkimage=`argument $option "$@"`; shift ;;
     --grub-mkimage=*)
        grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;