Skip to content

Commit 6804ba3

Browse files
webstechgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8104ec9 commit 6804ba3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

contrib/diff-highlight/DiffHighlight.pm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ use 5.008;
44
use warnings FATAL => 'all';
55
use strict;
66

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+
712
# Highlight by reversing foreground and background. You could do
813
# other things like bold or underline if you prefer.
914
my @OLD_HIGHLIGHT = (
@@ -134,7 +139,7 @@ sub highlight_stdin {
134139
# fallback, which means we will work even if git can't be run.
135140
sub color_config {
136141
my ($key, $default) = @_;
137-
my $s = `git config --get-color $key 2>/dev/null`;
142+
my $s = `git config --get-color $key 2>$NULL`;
138143
return length($s) ? $s : $default;
139144
}
140145

0 commit comments

Comments
 (0)