summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorZsolt Sz. Sztupák <zsolt.sztupak@gamesys.co.uk>2013-11-11 18:09:33 +0000
committerZsolt Sz. Sztupák <zsolt.sztupak@gamesys.co.uk>2013-11-11 18:09:33 +0000
commit96798c42f046fec7f01f53d10dd63f30ed6a1e07 (patch)
tree4d51072eb8bc513ca77cb278df659cab2ca06f0c /plugins
parente30a1243dc89814e9f31e4b4cc284d948ecbfbd8 (diff)
downloadzsh-96798c42f046fec7f01f53d10dd63f30ed6a1e07.tar.gz
zsh-96798c42f046fec7f01f53d10dd63f30ed6a1e07.tar.bz2
zsh-96798c42f046fec7f01f53d10dd63f30ed6a1e07.zip
Fix issues with special characters when running mvn
Setting the locale to C will stabilize sed, so it won't stop processing the mvn output when it encounters invalid characters (like binary data) This makes it also more viable to add the `alias mvn='mvn-color`, as the coloring is less obtrusive, and there won't be any issues with sed breaking because of an invalid character inside the stream
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mvn/mvn.plugin.zsh12
1 files changed, 7 insertions, 5 deletions
diff --git a/plugins/mvn/mvn.plugin.zsh b/plugins/mvn/mvn.plugin.zsh
index 799f6fc8c..0c9141907 100644
--- a/plugins/mvn/mvn.plugin.zsh
+++ b/plugins/mvn/mvn.plugin.zsh
@@ -24,16 +24,18 @@ export RESET_FORMATTING=`tput sgr0`
# Wrapper function for Maven's mvn command.
mvn-color()
{
- # Filter mvn output using sed
- mvn $@ | sed -e "s/\(\[INFO\]\ \-.*\)/${TEXT_BLUE}${BOLD}\1/g" \
- -e "s/\(\[INFO\]\ \[.*\)/${RESET_FORMATTING}${BOLD}\1${RESET_FORMATTING}/g" \
+ (
+ # Filter mvn output using sed. Before filtering set the locale to C, so invalid characters won't break some sed implementations
+ unset LANG
+ LC_CTYPE=C mvn $@ | sed -e "s/\(\[INFO\]\)\(.*\)/${TEXT_BLUE}${BOLD}\1${RESET_FORMATTING}\2/g" \
-e "s/\(\[INFO\]\ BUILD SUCCESSFUL\)/${BOLD}${TEXT_GREEN}\1${RESET_FORMATTING}/g" \
- -e "s/\(\[WARNING\].*\)/${BOLD}${TEXT_YELLOW}\1${RESET_FORMATTING}/g" \
- -e "s/\(\[ERROR\].*\)/${BOLD}${TEXT_RED}\1${RESET_FORMATTING}/g" \
+ -e "s/\(\[WARNING\]\)\(.*\)/${BOLD}${TEXT_YELLOW}\1${RESET_FORMATTING}\2/g" \
+ -e "s/\(\[ERROR\]\)\(.*\)/${BOLD}${TEXT_RED}\1${RESET_FORMATTING}\2/g" \
-e "s/Tests run: \([^,]*\), Failures: \([^,]*\), Errors: \([^,]*\), Skipped: \([^,]*\)/${BOLD}${TEXT_GREEN}Tests run: \1${RESET_FORMATTING}, Failures: ${BOLD}${TEXT_RED}\2${RESET_FORMATTING}, Errors: ${BOLD}${TEXT_RED}\3${RESET_FORMATTING}, Skipped: ${BOLD}${TEXT_YELLOW}\4${RESET_FORMATTING}/g"
# Make sure formatting is reset
echo -ne ${RESET_FORMATTING}
+ )
}
# Override the mvn command with the colorized one.