summaryrefslogtreecommitdiff
path: root/src/basic
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-05-30 18:23:54 +0200
committerLennart Poettering <lennart@poettering.net>2016-05-30 18:23:54 +0200
commitac96418b4f16c2a0acd2e4981e533c00fe21bdf1 (patch)
tree91b0a8925260b5e8ff2a468069f1f4287c84c5c6 /src/basic
parent7565bb98a45c51c7a79cbeda9905e5364c49e374 (diff)
pager: don't start pager if the terminal is explicitly set to TERM=dumb
As suggested here: https://bugs.freedesktop.org/show_bug.cgi?id=64737#c8 This adds a new call terminal_is_dumb() and makes use of this where appropriate.
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/terminal-util.c17
-rw-r--r--src/basic/terminal-util.h1
2 files changed, 15 insertions, 3 deletions
diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c
index 2b90f2e5a1..d8cca55378 100644
--- a/src/basic/terminal-util.c
+++ b/src/basic/terminal-util.c
@@ -1193,6 +1193,19 @@ int open_terminal_in_namespace(pid_t pid, const char *name, int mode) {
return receive_one_fd(pair[0], 0);
}
+bool terminal_is_dumb(void) {
+ const char *e;
+
+ if (!on_tty())
+ return true;
+
+ e = getenv("TERM");
+ if (!e)
+ return true;
+
+ return streq(e, "dumb");
+}
+
bool colors_enabled(void) {
static int enabled = -1;
@@ -1202,10 +1215,8 @@ bool colors_enabled(void) {
colors = getenv("SYSTEMD_COLORS");
if (colors)
enabled = parse_boolean(colors) != 0;
- else if (streq_ptr(getenv("TERM"), "dumb"))
- enabled = false;
else
- enabled = on_tty();
+ enabled = !terminal_is_dumb();
}
return enabled;
diff --git a/src/basic/terminal-util.h b/src/basic/terminal-util.h
index b449370974..169ab772ff 100644
--- a/src/basic/terminal-util.h
+++ b/src/basic/terminal-util.h
@@ -80,6 +80,7 @@ unsigned lines(void);
void columns_lines_cache_reset(int _unused_ signum);
bool on_tty(void);
+bool terminal_is_dumb(void);
bool colors_enabled(void);
static inline const char *ansi_underline(void) {