The attached patch goes a bit further in optimising (and making
redirection syntax consistent).

The idea is: one needs not echo:ing anything when the one and only need is
to truncate/touch a file.  IOW, this:

        echo -n >file

and this:

        >file

will truncate file, the latter without emploing help from echo.


Cheers,

-- 
Cristian
--- debian/postinst.in.orig	2011-05-29 13:23:53.000000000 +0200
+++ debian/postinst.in	2011-05-29 13:53:58.000000000 +0200
@@ -5,8 +5,8 @@
   if [ ! -d $1 ]; then
     mkdir -p $1
   fi
-  chown root:staff $1 2> /dev/null || true
-  chmod 2775 $1 2> /dev/null || true
+  chown root:staff $1 2>/dev/null || true
+  chmod 2775 $1 2>/dev/null || true
 }
 
 install_from_default() {
@@ -68,19 +68,19 @@
   ln -sf share/man /usr/local/man
 
   if [ ! -f /var/log/wtmp ]; then
-    echo -n>/var/log/wtmp
+    >/var/log/wtmp
   fi
   if [ ! -f /var/log/btmp ]; then
-    echo -n>/var/log/btmp
+    >/var/log/btmp
   fi
   if [ ! -f /var/log/lastlog ]; then
-    echo -n>/var/log/lastlog
+    >/var/log/lastlog
   fi
   chown root:utmp /var/log/wtmp /var/log/btmp /var/log/lastlog
   chmod 664 /var/log/wtmp /var/log/lastlog
   chmod 660 /var/log/btmp
   if [ ! -f /var/run/utmp ]; then
-    echo -n>/var/run/utmp
+    >/var/run/utmp
   fi
   chown root:utmp /var/run/utmp
   chmod 664 /var/run/utmp
@@ -91,7 +91,7 @@
   chown root:root /var/lib/dpkg
 fi
 if [ ! -f /var/lib/dpkg/status ]; then
-  echo > /var/lib/dpkg/status
+  >/var/lib/dpkg/status
   chmod 644 /var/lib/dpkg/status
   chown root:root /var/lib/dpkg/status
 fi
@@ -104,12 +104,12 @@
 
 if [ "$1" = "configure" ] && [ "$2" != "" ]; then
   if [ -f /etc/motd ]; then
-    oldmd=`awk 'NR > 2' /etc/motd | md5sum | awk '{print $1}'`
-    newmd=`awk 'NR > 2' /usr/share/base-files/motd | md5sum | awk '{print $1}'`
+    oldmd=`tail -n+3 /etc/motd | md5sum | cut -d' ' -f1`
+    newmd=`tail -n+3 /usr/share/base-files/motd | md5sum | cut -d' ' -f1`
     if [ "$oldmd" != "$newmd" ]; then
       if grep -q "$oldmd" /usr/share/base-files/motd.md5sums; then
-        awk 'NR <= 2' /etc/motd > /etc/motd.new
-        awk 'NR > 2' /usr/share/base-files/motd >> /etc/motd.new
+        head -n2 /etc/motd >/etc/motd.new
+        tail -n+3 /usr/share/base-files/motd >>/etc/motd.new
         mv /etc/motd /etc/motd.old
         mv /etc/motd.new /etc/motd
       fi

Reply via email to