Unfortunately that script has some quoting issues. It will work if you add this function to the code:
date () { command date "$*" }
Actually you don't need to alter the source. Do this: define the "date" function and export it:
$ date() { command date "$*"; } $ export -f date $ annotate-output "+foo %T" bash -c "echo stdout; echo stderr >&2" foo 10:38:30 I: Started bash -c echo stdout; echo stderr >&2 foo 10:38:30 E: stderr foo 10:38:30 O: stdout foo 10:38:30 I: Finished with exitcode 0
There might be problems if the thing you're annotating also calls date
.
If you care to fix annotate-output on your system, apply this diff
$ diff /usr/bin/annotate-output bin/annotate-output 28c28 < echo "`date $` $1: $line" --- > printf "%s %s: %s\n" "$(date "$FMT")" "$1" "$line" 78c78 < echo "`date $` I: Started $@" --- > addtime I <<< "Started $*" 83c83 < echo "`date $` I: Finished with exitcode $EXIT" --- > addtime I <<< "Finished with exitcode $EXIT"