[PATCH 2/2] annotate-output: Add option to supress input lines

Christian Ludwig cludwig at genua.de
Wed Dec 7 17:26:45 UTC 2016


Add an option to supress the ouput of the executed command and its
return value. The chosen default does not change behaviour.

The return value is propagated already, and the executed command is
known most of the time.
---
 scripts/annotate-output.1  |  3 +++
 scripts/annotate-output.sh | 19 +++++++++++++++----
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/scripts/annotate-output.1 b/scripts/annotate-output.1
index a6b3336..806bd2e 100644
--- a/scripts/annotate-output.1
+++ b/scripts/annotate-output.1
@@ -14,6 +14,9 @@ stderr. It maintains separate stdout and stderr streams in the output.
 Controls the timestamp format, as per \fBdate\fR(1).  Defaults to
 "%H:%M:%S".
 .TP
+\fB\-n\fR, \fB\-\-noinput\fR
+Supresses the output of input lines.
+.TP
 \fB\-h\fR, \fB\-\-help\fR
 Display a help message and exit successfully.
 
diff --git a/scripts/annotate-output.sh b/scripts/annotate-output.sh
index 8666b1b..b9bcb72 100755
--- a/scripts/annotate-output.sh
+++ b/scripts/annotate-output.sh
@@ -49,10 +49,12 @@ usage ()
   Run program and annotate STDOUT/STDERR with a timestamp.
 
   Options:
-   +FORMAT    - Controls the timestamp format as per date(1)
-   -h, --help - Show this message"
+   +FORMAT       - Controls the timestamp format as per date(1)
+   -n, --noinput - Supress output of input lines
+   -h, --help    - Show this message"
 }
 
+SHOWINPUT=true
 FMT="+%H:%M:%S"
 while [ "$1" ]; do
 	case "$1" in
@@ -64,6 +66,10 @@ while [ "$1" ]; do
 		usage
 		exit 0
 		;;
+	-n|--noinput)
+		SHOWINPUT=false
+		shift
+		;;
 	*)
 		break
 		;;
@@ -95,11 +101,16 @@ else
 	addprefix "${FMT#+} E" < $ERR >&2 &
 fi
 
-echo "Started $@" | addtime I
+if $SHOWINPUT ; then
+	echo "Started $@" | addtime I
+fi
+
 "$@" > $OUT 2> $ERR ; EXIT=$?
 rm -f $OUT $ERR
 wait
 
-echo "Finished with exitcode $EXIT" | addtime I
+if $SHOWINPUT ; then
+	echo "Finished with exitcode $EXIT" | addtime I
+fi
 
 exit $EXIT
-- 
2.1.4




More information about the devscripts-devel mailing list