diff-highlight: use correct /dev/null for UNIX and Windows
Use File::Spec->devnull() for output redirection to avoid messages when Windows version of Perl is first in path. The message 'The system cannot find the path specified.' is displayed each time git is run to get colors. Signed-off-by: Chris. Webster <chris@webstech.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Chris. Webster committed
Oct 31, 2018 at 23:58 UTC
6804ba3a58ff2999533af28ca5af3901e30fd1f2
1 file changed
+6
-1
contrib/diff-highlight/DiffHighlight.pm
+6
-1
@@ -4,6 +4,11 @@ use 5.008;
4
use warnings FATAL => 'all';
5
use strict;
6
7
+# Use the correct value for both UNIX and Windows (/dev/null vs nul)
8
+use File::Spec;
9
+
10
+my $NULL = File::Spec->devnull();
11
+
12
# Highlight by reversing foreground and background. You could do
13
# other things like bold or underline if you prefer.
14
my @OLD_HIGHLIGHT = (
@@ -134,7 +139,7 @@ sub highlight_stdin {
139
# fallback, which means we will work even if git can't be run.
140
sub color_config {
141
my ($key, $default) = @_;
137
- my $s = `git config --get-color $key 2>/dev/null`;
142
+ my $s = `git config --get-color $key 2>$NULL`;
143
return length($s) ? $s : $default;
144
}
145