# Shelved patch: broken help output
--- build-simple-cdd	2007-09-17 01:21:30 +0000
+++ build-simple-cdd	2007-10-16 05:39:44 +0000
@@ -6,33 +6,39 @@
 # FIXME: call with LANG=C for parts that need it
 
 get_help() {
-cat<<EOF
-simple-cdd - create custom debian-installer CDs
-
-Usage:
---conf  specify a configuration file
---dist  specify distribution (etch, lenny, sid)
---graphical-installer|-g  enable graphical installer by default
---serial-console|-s  set defaults for serial console
---do-mirror  generate mirror
---no-do-mirror  do not generate mirror
---profiles|-p  select profiles (examples in profiles/ dir)
---build-profiles|-b  profiles only used while building the CD
---auto-profiles|-a  automatically install these profiles
---local-packages  list of files included on CD's local package repository
---locale  select locale
---keyboard  select keyboard (console-keymaps-at/keymap debconf question)
---debian-mirror  specify debian mirror. default: ftp://ftp.us.debian.org/debian
---security-mirror  specify debian mirror. default is unset.
---proposed-updates  specify if proposed updates should be used. default is no.
---mirror-tools  list the mirror tools to be used
---kernel-packages  list of kernel packages to include on the CD
---help|-h  display this help
---qemu|-q  use qemu to test the image
---force-preseed  only issue a warning if a preseeding file is invalid
---profiles-udeb-dist  pull simple-cdd-profiles udeb from other distribution
---extra-udeb-dist  also pull in udebs from specified distribution
-EOF
+  test $# -gt 0 && {
+    exec 1>&2
+    echo "build-simple-cdd ERROR: $*"
+  }
+  cat<<- EOF
+	simple-cdd - create custom debian-installer CDs
+
+	Usage:
+	--conf  specify a configuration file
+	--dist  specify distribution (etch, lenny, sid)
+	--graphical-installer|-g  enable graphical installer by default
+	--serial-console|-s  set defaults for serial console
+	--do-mirror  generate mirror
+	--no-do-mirror  do not generate mirror
+	--profiles|-p  select profiles (examples in profiles/ dir)
+	--build-profiles|-b  profiles only used while building the CD
+	--auto-profiles|-a  automatically install these profiles
+	--local-packages  list of files included on CD's local package repository
+	--locale  select locale
+	--keyboard  select keyboard (console-keymaps-at/keymap debconf question)
+	--debian-mirror  specify debian mirror. default: ftp://ftp.us.debian.org/debian
+	--security-mirror  specify debian mirror. default is unset.
+	--proposed-updates  specify if proposed updates should be used. default is no.
+	--mirror-tools  list the mirror tools to be used
+	--kernel-packages  list of kernel packages to include on the CD
+	--help|-h  display this help
+	--qemu|-q  use qemu to test the image
+	--force-preseed  only issue a warning if a preseeding file is invalid
+	--profiles-udeb-dist  pull simple-cdd-profiles udeb from other distribution
+	--extra-udeb-dist  also pull in udebs from specified distribution
+	EOF
+
+  exit $#
 }
 
 commandline_opts="$@"
@@ -45,50 +51,47 @@
             echo "ERROR: simple-cdd configuration file not found: $2"
             exit 1
       fi
-      test -n "$1" && shift ;;
+      shift || get_help "missing argument to ${1} option" ;;
     --dist) export CODENAME="$2"
-      test -n "$1" && shift ;;
+      shift || get_help "missing argument to ${1} option" ;;
     -g|--g|--graphical-installer) export ISOLINUX_DEFAULT="installgui" ;;
     --serial-console|-s) use_serial_console="true" ;;
     --do-mirror) do_mirror="true" ;;
     --no-do-mirror) do_mirror="false" ;;
     --profiles|-p) profiles="$2" 
-      test -n "$1" && shift ;;
+      shift || get_help "missing argument to ${1} option" ;;
     --build-profiles|-b) build_profiles="$2" 
-      test -n "$1" && shift ;;
+      shift || get_help "missing argument to ${1} option" ;;
     --auto-profiles|-a) auto_profiles="$2" 
-      test -n "$1" && shift ;;
+      shift || get_help "missing argument to ${1} option" ;;
     --local-packages) local_packages="$2" 
-      test -n "$1" && shift ;;
+      shift || get_help "missing argument to ${1} option" ;;
     --locale) locale="$2" 
-      test -n "$1" && shift ;;
+      shift || get_help "missing argument to ${1} option" ;;
     --keyboard) keyboard="$2"
-      test -n "$1" && shift ;;
+      shift || get_help "missing argument to ${1} option" ;;
     --debian-mirror) debian_mirror="$2" 
-      test -n "$1" && shift ;;
+      shift || get_help "missing argument to ${1} option" ;;
     --security-mirror) security_mirror="$2" 
-      test -n "$1" && shift ;;
+      shift || get_help "missing argument to ${1} option" ;;
     --proposed-updates) proposed_updates="true" 
-      test -n "$1" && shift ;;
+      shift || get_help "missing argument to ${1} option" ;;
     --mirror-tools) mirror_tools="$2"
-      test -n "$1" && shift ;;
+      shift || get_help "missing argument to ${1} option" ;;
     --build-tools) build_tools="$2"
-      test -n "$1" && shift ;;
+      shift || get_help "missing argument to ${1} option" ;;
     --kernel-packages) kernel_packages="$2"
-      test -n "$1" && shift ;;
-    --help|-h) get_help 
-      exit 0 ;;
+      shift || get_help "missing argument to ${1} option" ;;
+    --help|-h) get_help  ;;
     --qemu|-q) use_qemu="true" ;;
     --force-preseed) force_preseed="true" ;;
     --profiles-udeb-dist) profiles_udeb_dist="$2"
-      test -n "$1" && shift ;;
+      shift || get_help "missing argument to ${1} option" ;;
     --extra-udeb-dist) extra_udeb_dist="$2"
-      test -n "$1" && shift ;;
-    *) echo "ERROR: unknown commandline option: $1" 
-      get_help
-      exit 1 ;;
+      shift || get_help "missing argument to ${1} option" ;;
+    *) get_help "unknown commandline option: $1"  ;;
   esac
-  test -n "$1" && shift
+  shift || get_help "could not shift off '$1' option"
 done
 
 # turn comma-separated list into whitespace-separated list
