Error messages are not correctly interleaved with output; for example:
Just spotted this report, message was spam-trapped. Can you provide an example where it fails in the manner you indicate? I don’t understand how you’d get diff output if one of the arguments were missing, say. Dave
Use -r, and diff two directories. For example: $ mkdir foo bar $ touch bar/baz $ cd foo; ln -s ../baz; cd .. $ colordiff -r foo bar diff: foo/baz: No such file or directory I presume once you can see how that is happening, it should be straightforward to see how stderr (line buffered by default) and stdout (block buffered by default) could be interleaved.
I cannot reproduce the behaviour you reported. davee@equinox:~/tmp/aaaa$ ls -lR .: total 8 drwxr-xr-x 2 davee users 4096 Nov 5 13:24 bar drwxr-xr-x 2 davee users 4096 Nov 5 13:24 foo ./bar: total 8 -rw-r--r-- 1 davee users 23 Nov 5 13:24 afile1 -rw-r--r-- 1 davee users 0 Nov 5 13:22 baz -rw-r--r-- 1 davee users 21 Nov 5 13:24 file1 ./foo: total 8 -rw-r--r-- 1 davee users 18 Nov 5 13:24 afile1 lrwxrwxrwx 1 davee users 6 Nov 5 13:23 baz -> ../baz -rw-r--r-- 1 davee users 15 Nov 5 13:24 file1 $ colordiff -r foo bar diff -r foo/afile1 bar/afile1 1c1 < Something is here --- diff: foo/baz: No such file or directory diff -r foo/file1 bar/file1 1c1 < This is a file --- What platform/OS/etc. does this happen on? Apart from not being able to reproduce the issue it does seem like a *very* unusual scenario where deliberately-broken links have been introduced. Dave.
Ubuntu 20.04 amd64. As I asked before, is stdout being flushed before possible stderr output?
To be honest I’m not sure. Feel free to inspect the source :-) I don’t really know how to address the issue but am open to suggestions! Dave -- Dave Ewart, davee@sungate.co.uk
As far as I can tell, STDOUT in perl is line buffered when connected to a terminal anyway (which should have been my case). Perhaps therefore the problem is that the diff process, as it's running asynchronously, might simply interleave its output in any case, and to fix it it would be necessary to capture its stderr…
I must be honest, I can't replicate the issue you are seeing at all, neither on Debian/10.x nor Ubuntu/20.04 LTS. This is using the packaged version of colordiff (which happens to be 1.0.18 in both cases). Testing the commands 'colordiff -r foo bar' and '/usr/bin/diff -r foo bar' for the artificially-created test case results in this output in both cases on Debian: diff -r foo/afile1 bar/afile1 1c1 < Something is here --- /usr/bin/diff: foo/baz: No such file or directory diff -r foo/file1 bar/file1 1c1 < This is a file --- On Ubuntu I get the same as above for the plain diff invocation and instead: diff: foo/baz: No such file or directory diff -r foo/afile1 bar/afile1 1c1 < Something is here --- diff -r foo/file1 bar/file1 1c1 < This is a file --- for the colordiff variant. None of the above show your original text where the line breaks were broken up:
This doesn't surprise me.
Closing bug, cannot reproduce the issue. Dave.