Last active
August 29, 2015 14:19
-
-
Save justlaputa/2e6bf484e02c5ebcf406 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Prepends a date string in front of the Maven output. | |
# A workaround for http://jira.codehaus.org/browse/MNG-519 "Timestamps on messages" | |
[ -z "${AWK}" ] && AWK="$(which gawk 2>/dev/null)" || AWK="$(which awk 2>/dev/null)" || { echo "Error: Could not find AWK tool."; exit 1; } | |
"${AWK}" 'BEGIN { print strftime("%Y-%m-%d %H:%M:%S"); }' 2>&1 > /dev/null || { echo "Error: your AWK version does not support strftime() function." && exit 1; } | |
mvn "${@}" 2>&1 |"${AWK}" '{ print strftime("%Y-%m-%d %H:%M:%S"), $0; fflush(); }' | |
# see comp.unix.shell FAQ: (http://cfajohnson.com/shell/cus-faq-2.html) | |
# "How do I get the exit code of cmd1 in cmd1|cmd2" | |
exit ${PIPESTATUS[0]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment