[PATCH 1/2] annotate-output: Maintain stdout/stderr
Christian Ludwig
cludwig at genua.de
Wed Dec 7 17:26:44 UTC 2016
Instead of printing everything to stdout, maintain separate streams for
stdout and stderr in the output.
This is useful for post-processing. So users do not have to grep the
output for ' O: ' and ' E: ', which is error-prone.
---
scripts/annotate-output.1 | 2 +-
scripts/annotate-output.sh | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/scripts/annotate-output.1 b/scripts/annotate-output.1
index f2fec00..a6b3336 100644
--- a/scripts/annotate-output.1
+++ b/scripts/annotate-output.1
@@ -6,7 +6,7 @@ annotate-output \- annotate program output with time and stream
.SH DESCRIPTION
\fBannotate\-output\fR will execute the specified program, while
prepending every line with the current time and O for stdout and E for
-stderr.
+stderr. It maintains separate stdout and stderr streams in the output.
.SH OPTIONS
.TP
diff --git a/scripts/annotate-output.sh b/scripts/annotate-output.sh
index 6929faa..8666b1b 100755
--- a/scripts/annotate-output.sh
+++ b/scripts/annotate-output.sh
@@ -86,13 +86,13 @@ ERR=$tmp/err
mkfifo $OUT $ERR || exit 1
if [ "${FMT/\%}" != "${FMT}" ] ; then
- addtime O < $OUT &
- addtime E < $ERR &
+ addtime O < $OUT >&1 &
+ addtime E < $ERR >&2 &
else
# If FMT does not contain a %, use the optimized version that
# does not call 'date'.
- addprefix "${FMT#+} O" < $OUT &
- addprefix "${FMT#+} E" < $ERR &
+ addprefix "${FMT#+} O" < $OUT >&1 &
+ addprefix "${FMT#+} E" < $ERR >&2 &
fi
echo "Started $@" | addtime I
--
2.1.4
More information about the devscripts-devel
mailing list