Use "grep -q" instead of "grep ... > /dev/null" in events.d/10.interfaces
authorMichael Adam <obnox@samba.org>
Wed, 10 Dec 2008 21:19:31 +0000 (22:19 +0100)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 11 Dec 2008 22:18:30 +0000 (09:18 +1100)
This enhances readability.

Michael

config/events.d/10.interface

index 4d070777269bb86b5f73b29ad252c66c92c23f99..01302ba67e0c2d7255f253be539e973ca29247b0 100755 (executable)
@@ -100,13 +100,13 @@ case $cmd in
        # this _very_ annoying behaviour we have to keep a record of the secondaries and re-add
        # them afterwards. yuck
        secondaries=""
-       if /sbin/ip addr list dev $iface primary | grep "inet $ip/$maskbits " > /dev/null; then
+       if /sbin/ip addr list dev $iface primary | grep -q "inet $ip/$maskbits " ; then
            secondaries=`/sbin/ip addr list dev $iface secondary | grep " inet " | awk '{print $2}'`
        fi
        /sbin/ip addr del $ip/$maskbits dev $iface || failed=1
        [ -z "$secondaries" ] || {
            for i in $secondaries; do
-               if /sbin/ip addr list dev $iface | grep "inet $i" > /dev/null; then
+               if /sbin/ip addr list dev $iface | grep -q "inet $i" ; then
                    echo "kept secondary $i on dev $iface"
                else 
                    echo "re-adding secondary address $i to dev $iface"
@@ -147,7 +147,7 @@ case $cmd in
            case $IFACE in 
            bond*)
                IFACE=`echo $IFACE |sed -e 's/\....$//'`
-               grep '^MII Status: up' /proc/net/bonding/$IFACE > /dev/null || {
+               grep -q '^MII Status: up' /proc/net/bonding/$IFACE || {
                        echo "ERROR: public network interface $IFACE is down"
                        exit 1
                }
@@ -157,7 +157,7 @@ case $cmd in
                ;;
            *)
                [ -z "$IFACE" ] || {
-                   /usr/sbin/ethtool $IFACE | grep 'Link detected: yes' > /dev/null || {
+                   /usr/sbin/ethtool $IFACE | grep -q 'Link detected: yes' || {
                        echo "ERROR: No link on the public network interface $IFACE"
                        exit 1
                    }