tests/eventscripts: Avoid errors on broken pipe
authorMartin Schwenke <martin@meltin.net>
Tue, 28 Jan 2014 03:34:15 +0000 (14:34 +1100)
committerAmitay Isaacs <amitay@gmail.com>
Fri, 31 Jan 2014 05:06:06 +0000 (16:06 +1100)
ctdb_get_my_public_addresses() attempts to echo things and this causes
an error if head has taken the first line and the pipe is closed.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Fri Jan 31 05:30:38 CET 2014 on sn-devel-104

(Imported from commit b112a3317cbedc73a6e17b3f711fec84f0d41d4e)

tests/eventscripts/scripts/local.sh

index e6186a07230c12b812511e4696099267554bf66f..6099da36137bf7d2584b327d3ec430c734f7c783 100644 (file)
@@ -401,7 +401,7 @@ ctdb_get_my_public_addresses ()
 # This is suitable for passing to takeip/releaseip
 ctdb_get_1_public_address ()
 {
-    ctdb_get_my_public_addresses | head -n 1
+    ctdb_get_my_public_addresses | { head -n 1 ; cat >/dev/null ; }
 }
 
 ctdb_not_implemented ()
@@ -450,7 +450,7 @@ create_policy_routing_config ()
     if [ "$_num_ips" = "all" ] ; then
        cat
     else
-       head -n "$_num_ips"
+       { head -n "$_num_ips" ; cat >/dev/null ; }
     fi |
     while read _dev _ip _bits ; do
        _net=$(ipv4_host_addr_to_net "$_ip" "$_bits")
@@ -479,7 +479,7 @@ check_routes ()
     if [ "$_num_ips" = "all" ] ; then
        cat
     else
-       head -n "$_num_ips"
+       { head -n "$_num_ips" ; cat >/dev/null ; }
     fi | {
        while read _dev _ip _bits ; do
            _net=$(ipv4_host_addr_to_net "$_ip" "$_bits")