aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2010-12-08 01:16:01 +0000
committerMike Frysinger <vapier@gentoo.org>2010-12-08 01:16:01 +0000
commit4f205d1636b75df36cd24e8d85a51c0254d0df42 (patch)
tree9671658237e4ecb39f83880bfca28c10732af82e /paxinc.c
parentchange to simpler const argv0 string (diff)
downloadpax-utils-4f205d1636b75df36cd24e8d85a51c0254d0df42.tar.gz
pax-utils-4f205d1636b75df36cd24e8d85a51c0254d0df42.tar.bz2
pax-utils-4f205d1636b75df36cd24e8d85a51c0254d0df42.zip
add a -C/--nocolor option and respect env $NOCOLOR #332289
Diffstat (limited to 'paxinc.c')
-rw-r--r--paxinc.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/paxinc.c b/paxinc.c
index 61939a7..12fc43b 100644
--- a/paxinc.c
+++ b/paxinc.c
@@ -1,7 +1,7 @@
/*
* Copyright 2003-2007 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxinc.c,v 1.13 2009/03/15 08:52:59 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxinc.c,v 1.14 2010/12/08 01:16:01 vapier Exp $
*
* Copyright 2005-2007 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2007 Mike Frysinger - <vapier@gentoo.org>
@@ -143,3 +143,20 @@ const char *strfileperms(const char *fname)
return buf + 2;
}
+
+/* Color helpers */
+#define COLOR(c,b) "\e[" c ";" b "m"
+const char *NORM = COLOR("00", "00");
+const char *RED = COLOR("31", "01");
+const char *YELLOW = COLOR("33", "01");
+
+void color_init(bool disable)
+{
+ if (!disable) {
+ const char *nocolor = getenv("NOCOLOR");
+ if (nocolor)
+ disable = !strcmp(nocolor, "yes") || !strcmp(nocolor, "true");
+ }
+ if (disable)
+ NORM = RED = YELLOW = "";
+}