Package: colordiff
Version: 1.0.16-1
Severity: normal
Tags: patch
Dear Maintainer,
The README says that one can do:
If you want to force disable colour escape sequences (for example
pipe the output to patch), you can use option '--color=no' to do
so:
$ diff -u file1 file2 | colordiff --color=no | patch -p0 -d
another-working-dir
However in 1.0.16 this does not work bcause $color_patch is only used
if output is to a file:
if ((-f STDOUT) && ($color_patch == 0)) {
... disable color output ...
So I propose the attached patch to make sure that *if set*
$color_patch can override the automatic decisions either way.
It would also make sense to ship a /etc/colordiffrc file where
color_patches is set to auto, but whatever the case one would be able
to get the desired behavior by using --color=XXX on the command line.
-- System Information:
Debian Release: 9.0
APT prefers testing
APT policy: (990, 'testing'), (500, 'stable')
Architecture: amd64
(x86_64)
Foreign Architectures: i386
Kernel: Linux 4.9.0-2-amd64 (SMP w/8 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages colordiff depends on:
ii perl 5.24.1-2
colordiff recommends no packages.
colordiff suggests no packages.
-- Configuration Files:
/etc/colordiffrc changed:
banner=no
color_patches=auto
diff_cmd=diff
plain=off
newtext=darkgreen
oldtext=darkred
diffstuff=darkcyan
cvsstuff=cyan
-- no debconf information
--- colordiff 2015-10-26 15:50:33.000000000 +0100
+++ colordiff.new 2017-05-18 05:27:38.616380978 +0200
@@ -31,7 +31,7 @@
my $app_www = 'http://www.colordiff.org/';
my $copyright = '(C)2002-2015';
my $show_banner = 1;
-my $color_patch = 0;
+my $color_patch = undef;
my $diff_cmd = "diff";
# ANSI sequences for colours
@@ -210,6 +210,8 @@
if ($setting eq 'color_patches') {
if ($value eq 'yes') {
$color_patch = 1;
+ } elsif ($value eq 'no') {
+ $color_patch = 0;
}
next;
}
@@ -269,12 +271,13 @@
$color_patch = 1;
} elsif ($color_mode eq "no") {
$color_patch = 0;
+} elsif ($color_mode eq "auto") {
+ $color_patch = undef;
}
-# If output is to a file, switch off colours, unless 'color_patch' is set,
-# which might be due to --color=no being specified
+# If output is to a file, switch off colours unless overriden by $color_patch.
# Relates to http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=378563
-if ((-f STDOUT) && ($color_patch == 0)) {
+if (!$color_patch && (defined $color_patch || -f STDOUT)) {
$plain_text = '';
$file_old = '';
$file_new = '';