#996894 colordiff: Error messages interrupt output

Package:
colordiff
Source:
colordiff
Submitter:
Reuben Thomas
Date:
2022-06-05 20:45:04 UTC
Severity:
normal
Tags:
#996894#5
Date:
2021-10-20 11:07:55 UTC
From:
To:
Error messages are not correctly interleaved with output; for example:
#996894#10
Date:
2021-11-03 17:24:00 UTC
From:
To:
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

#996894#15
Date:
2021-11-05 13:03:07 UTC
From:
To:
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.

#996894#20
Date:
2021-11-09 17:01:30 UTC
From:
To:
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.

#996894#25
Date:
2021-11-09 17:17:26 UTC
From:
To:

Ubuntu 20.04 amd64.

As I asked before, is stdout being flushed before possible stderr output?

#996894#30
Date:
2021-11-09 17:45:16 UTC
From:
To:
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

#996894#35
Date:
2021-11-09 18:26:12 UTC
From:
To:
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…

#996894#40
Date:
2021-11-12 10:27:52 UTC
From:
To:
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:

#996894#45
Date:
2021-11-12 10:53:36 UTC
From:
To:
This doesn't surprise me.
#996894#52
Date:
2022-06-05 20:42:43 UTC
From:
To:
Closing bug, cannot reproduce the issue.

Dave.