The following should be POSIXly correct and portable, right?
$ mkfifo f1 f2
$ (ls >f1 & ls -a >f2 & diff f1 f2)
Expected output: difference between 'ls' and 'ls -a' output.
(The (subshell) is just for suppressing job control noise.)
This works on every unixy system, it seems, *except* Solaris, which
quietly detects no difference. It fails at least on Solaris 10.1 through >11.4, as well as OpenIndiana.
In article <h4s80iF60a0U1@mid.individual.net>,
Martijn Dekker <martijn@inlv.demon.nl> wrote:
The following should be POSIXly correct and portable, right?
$ mkfifo f1 f2
$ (ls >f1 & ls -a >f2 & diff f1 f2)
Expected output: difference between 'ls' and 'ls -a' output.
(The (subshell) is just for suppressing job control noise.)
This works on every unixy system, it seems, *except* Solaris, which
quietly detects no difference. It fails at least on Solaris 10.1 through
11.4, as well as OpenIndiana.
You are mistaken, it works on every UNIX the way it does on Solaris... _except_ when the platform used "gdiff".
This includes e.g. older versions of FreeBSD but not any newer *BSD since *BSD
tris to avoid non-free licenses since a while.
I would say, there is still a bug in the UNIX diff, but this differs from what
you believe:
diff should probably print that there was a seek error....
because you cannot seek a pipe.
.(etc)
..
.(etc)
..
The reason why your proposal diff <(cat f1) <(cat f2) works is because the output of cat is directed to a /tmp/ file that is openend and passwed as /dev/fd/# to diff.This statement cannot possibly be right. Not only would it defeat the
That is rich, coming from someone who just claimed with a straight face
and a wagging finger that only the evil GNU diff is capable of dealing
with non-seekable input.
When /dev/stdin or /dev/fd/* are connected to pipes, you can't seek them
any more than you can directly seek a FIFO. Yet, the above works.
And there is no reason why it shouldn't work. Diff is a linear
operation, so seeking is not necessary. At most it's an optimisation,
and optimisations can be disabled.
Clearly, then, Solaris diff does not, and does not need to, require the >ability to seek. It's got some very specific problem with being given a
FIFO directly as an argument, that's all.
I don't know whether that strange behaviour is POSIX compliant or not (I
now strongly suspect it's not, though) but it certainly looks like a
bug. There is zero reason why that shouldn't work.
It is good practice to first read all postings before answering.
So why didn't you just also admit your mistake?
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 293 |
Nodes: | 16 (2 / 14) |
Uptime: | 233:30:31 |
Calls: | 6,624 |
Files: | 12,172 |
Messages: | 5,319,629 |