about summary refs log tree commit diff
path: root/mcolor
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2018-01-29 15:34:53 +0100
committerLeah Neukirchen <leah@vuxu.org>2018-01-29 15:34:53 +0100
commit4014f03afe6d624ba1c6bdde6551b4996ba31fe5 (patch)
tree1b0a162f261f4b82c015e405d10354676c48ad41 /mcolor
parent1f0b8a7d6dd0a8a7aeb97561c379eb0c25bb5d64 (diff)
downloadmblaze-4014f03afe6d624ba1c6bdde6551b4996ba31fe5.tar.gz
mblaze-4014f03afe6d624ba1c6bdde6551b4996ba31fe5.tar.xz
mblaze-4014f03afe6d624ba1c6bdde6551b4996ba31fe5.zip
mcolor: support $NO_COLOR
http://no-color.org/
Diffstat (limited to 'mcolor')
-rwxr-xr-xmcolor4
1 files changed, 2 insertions, 2 deletions
diff --git a/mcolor b/mcolor
index e88c052..d3a402a 100755
--- a/mcolor
+++ b/mcolor
@@ -4,8 +4,8 @@
 function co(n, c) { e = ENVIRON["MCOLOR_" n]; return e ? e : c }
 function fg(c, s) { return sprintf("\033[38;5;%03dm%s\033[0m", c, s) }
 function so(s) { return sprintf("\033[1m%s\033[0m", s) }
-BEGIN { hdr = 1; if (match(ENVIRON["TERM"], "^(dumb|network|9term)")) dumb = 1 }
-dumb { print; next }
+BEGIN { hdr = 1; if ("NO_COLOR" in ENVIRON || match(ENVIRON["TERM"], "^(dumb|network|9term)")) no_color = 1 }
+no_color { print; next }
 /\r$/ { sub(/\r$/, "") }
 /^\014$/ { nextmail = 1; next }
 /^$/ { hdr = 0 }