blob: 33f81e4fa2aae61f1b38b02747911f42f5294e3a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
From 697c1f4fa93ac971c487725e9e53fc211cd3c670 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@fb.com>
Date: Mon, 8 Aug 2016 18:50:15 -0700
Subject: diff: disable colorization for TERM=dumb
* src/diff.c (main): With --color or --color=auto, when TERM is
"dumb", disable colorization. Suggested by Daniel Colascione.
* NEWS (Bug fixes): Mention it.
* tests/colors: Add a test that would fail without this change,
yet passes with it.
---
diff --git a/src/diff.c b/src/diff.c
index 9bc1d96..686945e 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -656,6 +656,13 @@ main (int argc, char **argv)
prev = c;
}
+ if (colors_style == AUTO)
+ {
+ char const *t = getenv ("TERM");
+ if (t && STREQ (t, "dumb"))
+ colors_style = NEVER;
+ }
+
if (output_style == OUTPUT_UNSPECIFIED)
{
if (show_c_function)
diff --git a/tests/colors b/tests/colors
index 3ad2206..8651a5b 100755
--- a/tests/colors
+++ b/tests/colors
@@ -86,6 +86,11 @@ test $? = 1 || fail=1
gen_exp_default > exp || framework_failure_
compare exp out || fail=1
+TERM=dumb diff ---presume-output-tty --color=auto a b > out
+test $? = 1 || fail=1
+gen_exp_default > exp || framework_failure_
+compare exp out || fail=1
+
diff --color=never a b > out
test $? = 1 || fail=1
gen_exp_default > exp || framework_failure_
--
cgit v1.0
|