96798c42f046fec7f01f53d10dd63f30ed6a1e07

Author
Zsolt Sz. Sztupák <zsolt.sztupak@gamesys.co.uk>
Committer
Zsolt Sz. Sztupák <zsolt.sztupak@gamesys.co.uk>
Date

Message

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

Diff

This diff is truncated to protect this page.

 1diff --git a/plugins/mvn/mvn.plugin.zsh b/plugins/mvn/mvn.plugin.zsh
 2index 799f6fc8c551780fa1f4ef5429e1374fb61705ca..0c914190762be679ca6e429ac5428ed210b8876c 100644
 3--- a/plugins/mvn/mvn.plugin.zsh
 4+++ b/plugins/mvn/mvn.plugin.zsh
 5@@ -24,16 +24,18 @@ export RESET_FORMATTING=`tput sgr0`
 6 # Wrapper function for Maven's mvn command.
 7 mvn-color()
 8 {
 9-  # Filter mvn output using sed
10-  mvn $@ | sed -e "s/\(\[INFO\]\ \-.*\)/${TEXT_BLUE}${BOLD}\1/g" \
11-               -e "s/\(\[INFO\]\ \[.*\)/${RESET_FORMATTING}${BOLD}\1${RESET_FORMATTING}/g" \
12+  (
13+  # Filter mvn output using sed. Before filtering set the locale to C, so invalid characters won't break some sed implementations
14+  unset LANG
15+  LC_CTYPE=C mvn $@ | sed -e "s/\(\[INFO\]\)\(.*\)/${TEXT_BLUE}${BOLD}\1${RESET_FORMATTING}\2/g" \
16                -e "s/\(\[INFO\]\ BUILD SUCCESSFUL\)/${BOLD}${TEXT_GREEN}\1${RESET_FORMATTING}/g" \
17-               -e "s/\(\[WARNING\].*\)/${BOLD}${TEXT_YELLOW}\1${RESET_FORMATTING}/g" \
18-               -e "s/\(\[ERROR\].*\)/${BOLD}${TEXT_RED}\1${RESET_FORMATTING}/g" \
19+               -e "s/\(\[WARNING\]\)\(.*\)/${BOLD}${TEXT_YELLOW}\1${RESET_FORMATTING}\2/g" \
20+               -e "s/\(\[ERROR\]\)\(.*\)/${BOLD}${TEXT_RED}\1${RESET_FORMATTING}\2/g" \