Michael Tokarev: some cleanups for checkarray

Michael Tokarev mjt at alioth.debian.org
Thu Aug 23 17:54:24 UTC 2012


Module: mdadm
Branch: master
Commit: cfe0c9acd3f76e9da7a3c44617fce46134905d70
URL:    http://git.debian.org/?p=pkg-mdadm/mdadm.git;a=commit;h=cfe0c9acd3f76e9da7a3c44617fce46134905d70

Author: Michael Tokarev <mjt at tls.msk.ru>
Date:   Fri Jun 22 18:26:30 2012 +0400

some cleanups for checkarray

   - change --help printing and shorten/simplify the text
   - make --quiet cumulative and stop documenting --real-quiet
   - do not prduce help in case of incorrect usage, and exit with 1

---

 debian/changelog  |    4 +++
 debian/checkarray |   72 +++++++++++++++++++++++++----------------------------
 2 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 102790b..d0bb8f1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -10,6 +10,10 @@ mdadm (3.2.5-2) UNRELEASED; urgency=low
 
   [ Michael Tokarev ]
   * fix spelling mistakes in previous changelog entry
+  * some cleanups for checkarray:
+   - change --help printing and shorten/simplify the text
+   - make --quiet cumulative and stop documenting --real-quiet
+   - do not prduce help in case of incorrect usage, and exit with 1
 
   [ Dmitrijs Ledkovs ]
   * Use dh_installinit with --no-restart-on-upgrade, which will start
diff --git a/debian/checkarray b/debian/checkarray
index a3e5a6b..88266c4 100644
--- a/debian/checkarray
+++ b/debian/checkarray
@@ -11,46 +11,42 @@ PROGNAME=${0##*/}
 
 about()
 {
-  echo "$PROGNAME -- MD array (RAID) redundancy checker tool"
-  echo "Copyright © martin f. krafft <madduck at debian.org>"
-  echo "Released under the terms of the Artistic Licence 2.0"
+  echo "\
+$PROGNAME -- MD array (RAID) redundancy checker tool
+Copyright © martin f. krafft <madduck at debian.org>
+Released under the terms of the Artistic Licence 2.0"
 }
 
 usage()
 {
   about
-  echo
-  echo "Usage: $PROGNAME [options] [arrays]"
-  echo
-  echo "Valid options are:"
-  cat <<-_eof | column -s\& -t
-	-a|--all & check all assembled arrays (check /proc/mdstat).
-	-s|--status & print redundancy check status of devices.
-	-x|--cancel & queue a request to cancel a running redundancy check.
-	-i|--idle & perform check in a lowest scheduling class (idle)
-	-l|--slow & perform check in a lower-than-standard scheduling class
-	-f|--fast & perform check in higher-than-standard scheduling class
-	--realtime & perform check in real-time scheduling class (DANGEROUS!)
-	-c|--cron & honour AUTOCHECK setting in /etc/default/mdadm.
-	-q|--quiet & suppress informational messages.
-	-Q|--real-quiet & suppress all output messages, including warnings and errors.
-	-h|--help & show this output.
-	-V|--version & show version information.
-	_eof
-  echo
-  echo "Examples:"
-  echo "  $PROGNAME --all --idle"
-  echo "  $PROGNAME --quiet /dev/md[123]"
-  echo "  $PROGNAME -sa"
-  echo "  $PROGNAME -x --all"
-  echo
-  echo "Devices can be specified in almost any format. The following are"
-  echo "all equivalent:"
-  echo "  /dev/md0, md0, /dev/md/0, /sys/block/md0"
-  echo
-  echo "The --all option overrides all arrays passed to the script."
-  echo
-  echo "You can also control the status of a check with /proc/mdstat ."
+  echo "
+Usage: $PROGNAME [options] [arrays]
+
+Valid options are:
+ -a|--all	check all assembled arrays (ignores arrays in command line).
+ -s|--status	print redundancy check status of devices.
+ -x|--cancel	queue a request to cancel a running redundancy check.
+ -i|--idle	perform check in a lowest scheduling class (idle)
+ -l|--slow	perform check in a lower-than-standard scheduling class
+ -f|--fast	perform check in higher-than-standard scheduling class
+ --realtime	perform check in real-time scheduling class (DANGEROUS!)
+ -c|--cron	honour AUTOCHECK setting in /etc/default/mdadm.
+ -q|--quiet	suppress informational messages
+		(use twice to suppress error messages too).
+ -h|--help	show this output.
+ -V|--version	show version information.
+
+Examples:
+ $PROGNAME --all --idle
+ $PROGNAME --quiet /dev/md[123]
+ $PROGNAME -sa
+ $PROGNAME -x --all
+
+Devices can be specified in almost any format. The following are equivalent:
+ /dev/md0, md0, /dev/md/0, /sys/block/md0
+
+You can also control the status of a check with /proc/mdstat file."
 }
 
 SHORTOPTS=achVqQsxilf
@@ -76,15 +72,15 @@ for opt in $@; do
     -f|--fast) ionice=high;;
     --realtime) ionice=realtime;;
     -c|--cron) cron=1;;
-    -q|--quiet) quiet=1;;
-    -Q|--real-quiet) quiet=2;;
+    -q|--quiet) quiet=$(($quiet+1));;
+    -Q|--real-quiet) quiet=$(($quiet+2));;	# for compatibility
     -h|--help) usage; exit 0;;
     -V|--version) about; exit 0;;
     /dev/md/*|md/*) arrays="${arrays:+$arrays }md${opt#*md/}";;
     /dev/md*|md*) arrays="${arrays:+$arrays }${opt#/dev/}";;
     /sys/block/md*) arrays="${arrays:+$arrays }${opt#/sys/block/}";;
     --) :;;
-    *) echo "$PROGNAME: E: invalid option: $opt" >&2; usage >&2; exit 0;;
+    *) echo "$PROGNAME: E: invalid option: $opt.  Try --help." >&2; exit 1;;
   esac
 done
 




More information about the pkg-mdadm-commits mailing list