
The Tar Pipe (2010) - callum85
http://blog.extracheese.org/2010/05/the-tar-pipe.html?hn
======
JadeNB
> stdin, stdout, and stderr are files 0, 1, and 2. Always.

Shouldn't this be something closer to "stdin, stdout, and stderr are always
_initially_ fds 0, 1, and 2"? I thought that one could play some trickery to
change this. (I'm not being intentionally snarky, and might be quite wrong.)

~~~
falcolas
They can, yes. If you close all of them, the next files you open will get the
0, 1, and 2 file descriptors.

It's a fairly common idiom to close everything, open a handle to /dev/null,
and duplicate it twice to get 0, 1, and 2 pointing at /dev/null.

------
gwern
A nice writeup, but I'm curious what the tar pipe gains over a more normal way
of copying directories like 'cp -a'. (Or is that what it means by 'mostly
obsolete'?)

~~~
callum85
For some reason, 'tar|tar' is many times faster than 'cp -a' (at least, when
you're copying thousands of small files in deeply nested directories, on OS
X). I noticed this once through experimenation, tried to find out why, and
never got a good answer.

The other thing is that hard-linked files are apparently handled differently:
[http://stackoverflow.com/questions/316078/interesting-
usage-...](http://stackoverflow.com/questions/316078/interesting-usage-of-tar-
but-what-is-happening)

------
LeoPanthera
What's the point of "-f -"? Why not just omit -f entirely?

~~~
crest
Most tar implementations default to the first streamer (e.g. sa0) instead of
stdout.

