I have one file and one input coming from a pipe. They're identical. So why does colordiff
report differences?:
echo "123" | colordiff <(echo "123") -
1d0
< 123
It looks that this is colordiff causing the problem. With pure diff, all works OK.
colordiffpipe
I have one file and one input coming from a pipe. They're identical. So why does colordiff
report differences?:
echo "123" | colordiff <(echo "123") -
1d0
< 123
It looks that this is colordiff causing the problem. With pure diff, all works OK.
Best Answer
Using diff
This works for me. Would seem to be an issue with your particular version of
diff
?Example
My version
You could also try this alternative form:
But either way it should report that they're identical.
What about colordiff?
Well this method shows they're the same.
However as you've indicated using
echo
does in fact report these 2 strings as being different:But realize that
colordiff
is really just a Perl script wrapper around GNU diff.Since it's a Perl script you can run the script through the Perl debugger to see what's happening:
I think the bottom line here is that
colordiff
is not equipped to take input via STDIN (-
), it's only designed to take input from files.Searching there are several bugs filed regarding the lack of this feature:
Development branch of colordiff
I found this on github, kimmel/colordiff. Looks to be a newer version which handles STDIN better, in my cursory glance at the source.
Alternative forms that work
You can use
diff
to do the generation of differences and then pipe the output tocolordiff
afterwards.I found this in daveewart's fork/branch of
colordiff
, available here on github. There are a fairly large number of other forms that you can callcolordiff
, perhaps one of those would suit your needs.