cleanup docs, getopt arg parsing
[automated-distro-installer] / fresize
diff --git a/fresize b/fresize
index 68c12bd129de1e24acf2fd38436ad16d23d70aee..f08f4a6fa2c3a2eff6edc79dc9650675f5783d6e 100755 (executable)
--- a/fresize
+++ b/fresize
@@ -50,33 +50,37 @@ errcatch
 
 usage() {
     cat <<EOF
-Usage: ${0##*/} [-n] +/-SIZE[g] swap|boot
+Usage: ${0##*/} [OPTIONS] +/-SIZE[g] swap|boot
 
 Assuming Ian Kelling's partition scheme,
 Resize swap or boot, expanding or shrinking the root fs and partition to compensate.
 
 -n         Dry run
 -r         Reboot now if it's needed.
--h|--help  Print help.
+-h|--help  Print help and exit.
 
 SIZE is MiB, or if g is specified, GiB.
 
 If using multiple devices, SIZE is applied to each device, so total change is
 SIZE * devices.
 
-
+Note: Uses GNU getopt options parsing style
 EOF
     exit $1
 }
 
 reboot_not=false
 dry_run=false
+
+temp=$(getopt -l opt o "$@") || usage 1
+eval set -- "$temp"
 while true; do
     case $1 in
         -r) reboot_now=true; shift ;;
         -n) dry_run=true; shift ;;
         -h|--help) usage ;;
-        *) break ;;
+        --) shift; break ;;
+        *) echo "$0: Internal error!" ; exit 1 ;;
     esac
 done