summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2015-02-25 10:06:40 +0100
committerKarel Zak <kzak@redhat.com>2015-03-12 10:10:12 +0100
commitdecbd34d6fa69e0f47bcaef565b9305a4bf3f08b (patch)
treec8d62b108aa2c27e306fdae3163bc496e7bf5ff4
parent6f1e158f9d108b47a8546fcbee1030b644ba58ed (diff)
downloadutil-linux-decbd34d6fa69e0f47bcaef565b9305a4bf3f08b.tar.gz
build-sys: add --disable-colors-default
The current util-linux is to have enabled colorized outputs by default, this default behavior is possible to change by new configure option --disable-colors-default. Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--configure.ac10
-rw-r--r--lib/colors.c13
2 files changed, 21 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac
index 4ae450663..122b5d532 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1849,6 +1849,7 @@ AC_ARG_ENABLE([makeinstall-chown],
)
AM_CONDITIONAL([MAKEINSTALL_DO_CHOWN], [test "x$enable_makeinstall_chown" = xyes])
+
AC_ARG_ENABLE([makeinstall-setuid],
AS_HELP_STRING([--disable-makeinstall-setuid], [do not do setuid chmod operations during "make install"]),
[], [enable_makeinstall_setuid=yes]
@@ -1856,6 +1857,15 @@ AC_ARG_ENABLE([makeinstall-setuid],
AM_CONDITIONAL([MAKEINSTALL_DO_SETUID], [test "x$enable_makeinstall_setuid" = xyes])
+AC_ARG_ENABLE([colors-default],
+ AS_HELP_STRING([--disable-colors-default], [do not colorize output from utils by default]),
+ [], [enable_colors_default=yes]
+)
+AS_IF([test "x$enable_colors_default" = xyes], [
+ AC_DEFINE([USE_COLORS_BY_DEFAULT], [1], [Enables colorized output from utils by default])
+])
+
+
AC_ARG_VAR([SUID_CFLAGS],
[CFLAGS used for binaries which are usually with the suid bit])
AC_ARG_VAR([SUID_LDFLAGS],
diff --git a/lib/colors.c b/lib/colors.c
index 6f79ac4a8..2e5af48d9 100644
--- a/lib/colors.c
+++ b/lib/colors.c
@@ -19,6 +19,15 @@
#include "debug.h"
/*
+ * Default behavior, maybe be override by terminal-colors.d/{enable,disable}.
+ */
+#ifdef USE_COLORS_BY_DEFAULT
+# define UL_COLORMODE_DEFAULT UL_COLORMODE_AUTO /* check isatty() */
+#else
+# define UL_COLORMODE_DEFAULT UL_COLORMODE_NEVER /* no colors by default */
+#endif
+
+/*
* terminal-colors.d debug stuff
*/
UL_DEBUG_DEFINE_MASK(termcolors);
@@ -678,7 +687,7 @@ int colors_init(int mode, const char *name)
if (mode == UL_COLORMODE_UNDEF && (atty = isatty(STDOUT_FILENO))) {
int rc = colors_read_configuration(cc);
if (rc)
- cc->mode = UL_COLORMODE_AUTO;
+ cc->mode = UL_COLORMODE_DEFAULT;
else {
/* evaluate scores */
@@ -686,7 +695,7 @@ int colors_init(int mode, const char *name)
cc->scores[UL_COLORFILE_ENABLE])
cc->mode = UL_COLORMODE_NEVER;
else
- cc->mode = UL_COLORMODE_AUTO;
+ cc->mode = UL_COLORMODE_DEFAULT;
atexit(colors_deinit);
}