ctdb-tests: Tweak debug function
authorMartin Schwenke <martin@meltin.net>
Mon, 12 Feb 2018 04:41:09 +0000 (15:41 +1100)
committerAmitay Isaacs <amitay@samba.org>
Wed, 28 Mar 2018 00:57:16 +0000 (02:57 +0200)
Output to stderr.  Read from stdin if no arguments given, making it
possible to handle long lines using here documents.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/eventscripts/scripts/local.sh

index 573ce86c960b23b18e402168c2f851f4db744759..098b305034be68fc7f20cebea650c50e46f33700 100644 (file)
@@ -57,9 +57,16 @@ mkdir -p "$FAKE_NETWORK_STATE"
 ######################################################################
 
 if "$TEST_VERBOSE" ; then
-    debug () { echo "$@" ; }
+       debug ()
+       {
+               if [ -n "$1" ] ; then
+                       echo "$@" >&2
+               else
+                       cat >&2
+               fi
+       }
 else
-    debug () { : ; }
+       debug () { : ; }
 fi
 
 ######################################################################