Take the 2-minute tour ×

How come I can do this in bash:

$ diff -u <(echo -e "line1\nline2") <(echo -e "line1\nline3")
--- /dev/fd/63  2009-03-30 09:49:07.527272646 +0100
+++ /dev/fd/62  2009-03-30 09:49:07.527272646 +0100
@@ -1,2 +1,2 @@

i.e. I can use named pipes / process substituion to get the diff of a small chunk of text. However when I try to do it with wdiff, the diff for words, not just lines, I get no useful output


UPDATE: looks like there's an existing ubuntu bug report for this: https://bugs.launchpad.net/ubuntu/+source/wdiff/+bug/160912

share|improve this question

2 Answers 2

up vote 9 down vote accepted

An strace reveals that wdiff stats the files (probably to find out their size). Since named pipes report a size of 0 it probably assumes that both files are empty and therefore equal:

$ strace -efile wdiff -1 <(echo -e "line1\nline2") <(echo -e "line1\nline3")
execve("/usr/bin/wdiff", ["wdiff", "-1", "/dev/fd/63", "/dev/fd/62"], [/* 44 vars */]) = 0
[snip uninteresting stuff]
stat64("/dev/fd/63", {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
open("/dev/fd/63", O_RDONLY)            = 3
open("/tmp/wdiff.MzPXmH", O_RDWR|O_CREAT|O_EXCL, 0600) = 4
stat64("/dev/fd/62", {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
open("/dev/fd/62", O_RDONLY)            = 4
open("/tmp/wdiff.5nma9j", O_RDWR|O_CREAT|O_EXCL, 0600) = 5
unlink("/tmp/wdiff.MzPXmH")             = 0
unlink("/tmp/wdiff.5nma9j")             = 0
{++}Process 27699 detached

Edit: also note that bash may use /dev/fd-style filenames instead of named pipes if the kernel supports it (most recent ones do, the example above shows this), but the effect is pretty much the same.

share|improve this answer
Yeah, reproduced. –  Tim Post Mar 30 '09 at 9:25
I can reproduce aswell. diff stats the files aswell, but it still works. –  Rory Mar 30 '09 at 10:06

My guess would be that wdiff is broken.

share|improve this answer
Funny that this answer should be voted down, considering that the accepted answer gives evidence that wdiff is, indeed, broken. –  Mark Probst Mar 30 '09 at 12:00
That's probably because the mere statement doesn't help a lot (note that I didn't downvote). –  Joachim Sauer Mar 30 '09 at 13:45

Your Answer


