Package: hdparm
Version: 5.8-1
Severity: minor
Tags: patch

The attached patch improves the initscript's output by bringing it into
line with the convention:

    Doing something to things: thing1 thing2.

E.g., either

   $ sudo ./hdparm start
   Setting disc parameters: /dev/hda.

or

   $ sudo ./hdparm start
   Setting parameters of disc: (none).


-- System Information:
Debian Release: 3.1
  APT prefers testing
  APT policy: (500, 'testing'), (50, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.10
Locale: [EMAIL PROTECTED], [EMAIL PROTECTED] (charmap=ISO-8859-15)

Versions of packages hdparm depends on:
ii  libc6                       2.3.2.ds1-20 GNU C Library: Shared libraries an

-- no debconf information
--- hdparm_ORIG 2005-02-11 16:18:40.000000000 +0100
+++ hdparm      2005-02-11 16:48:25.000000000 +0100
@@ -2,6 +2,23 @@
 
 set -e
 
+MYNAME="$0"
+report()
+{
+  echo "${MYNAME}: $*"
+}
+
+report_error()
+{
+  echo "${MYNAME}: Error: $*" >&2
+}
+
+report_error_and_exit()
+{
+  report_error "$*.  Exiting."
+  exit 1
+}
+
 case $1 in
   start|restart|reload|force-reload)
     ;;
@@ -9,13 +26,13 @@
     exit 0
     ;;
   *)
-    echo "Usage: $0 {stop|start|restart|reload|force-reload}" >&2
-    exit 1
+    echo "Usage: $MYNAME {stop|start|restart|reload|force-reload}" >&2
+    exit 3
     ;;
 esac
 
 if grep -w -q "nohdparm" /proc/cmdline ; then
-  echo "Skipping setup of disc parameters."
+  report "Skipping setup of disc parameters."
   exit 0
 fi
 
@@ -29,11 +46,10 @@
 fi
 
 if ! [ "$raidstat" = 'OK' ]; then
-  echo "RAID status not OK.  Exiting."
-  exit 0
+  report_error_and_exit "RAID status not OK"
 fi
 
-echo -n "Setting disc parameters:"
+echo -n "Setting parameters of disc:"
 
 DISC=
 DEFAULT=
@@ -82,10 +98,13 @@
 # Get blocks as far as the drive's write cache.
 /bin/sync
 
-egrep -v '^[[:space:]]*(#|$)' /etc/hdparm.conf | while read KEY SEP VALUE; do
- if [ "$NEXT_LINE" != 'go' ]; then
-  case $SEP in
-    '{')
+egrep -v '^[[:space:]]*(#|$)' /etc/hdparm.conf | \
+ {
+  ITEMS_ECHOED=no
+  while read KEY SEP VALUE; do
+   if [ "$NEXT_LINE" != 'go' ]; then
+    case $SEP in
+     '{')
        case $KEY in
          command_line)
            NEXT_LINE=go
@@ -101,7 +120,7 @@
            ;;
        esac
        ;;
-    =)
+     =)
        case $KEY in
          read_ahead_sect) 
           set_option -a$VALUE
@@ -161,18 +180,16 @@
            set_option -p$VALUE
           ;;
         *)
-          echo "unknown option $KEY"
-          exit 1
+          report_error_and_exit "Unknown option: $KEY"
           ;;
        esac
-    ;;
-    "")
-       case $KEY in
-         })
+       ;;
+     "")
+       case "$KEY" in
+         '}')
           if [ -z "$DISC" ]; then
              if [ "$WAS_RUN" != '1' ]; then
-               echo "No disk enabled. Exiting"
-               exit 1
+              report_error_and_exit "No disk enabled"
              fi
           fi
           if [ -n "$OPTIONS" ]; then
@@ -180,7 +197,12 @@
             /sbin/hdparm -q -f $DISC
 
             /sbin/hdparm $OPTIONS $DISC
-            echo -n " $DISC,"
+            if [ "$ITEMS_ECHOED" = yes ] ; then
+              echo -n ", $DISC"
+            else
+              echo -n " $DISC"
+              ITEMS_ECHOED=yes
+            fi
           fi       
            ;;
          quiet)
@@ -200,21 +222,23 @@
            set_option -Z
           ;;
          *)
-          echo "unknown option $KEY"
-          exit 1
+          report_error_and_exit "Unknown option: $KEY"
           ;;
        esac
-          ;;
-   *)
-     echo "unknown separator $SEP"
-     exit 1
-     ;;
-  esac
-else
-  $KEY $SEP $VALUE
-  NEXT_LINE=no-go
-  WAS_RUN=1
-fi
-done
-
-echo " done."
+       ;;
+     *)
+       report_error_and_exit "Unknown separator: $SEP"
+       ;;
+    esac
+  else
+   $KEY $SEP $VALUE
+   NEXT_LINE=no-go
+   WAS_RUN=1
+  fi
+ done
+ if [ "$ITEMS_ECHOED" = yes ] ; then
+  echo "."
+ else
+  echo " (none)."
+ fi
+}

Reply via email to