On Fri, Oct 16, 2009 at 8:58 AM, hugo rivera <uai...@gmail.com> wrote:
> I am having a hard time understanding the dircp script and the dup(3)
> device. What's exactly the purpose of writing
> @{builtin cd $1 && tar cf /fd/1 .} | @{builtin cd $2 && tar xTf /fd/0}
> instead of
> {builtin cd $1 && tar c .} | {builtin cd $2 && tar xT}

your version is fine except that you dropped the @.
the author of dircp either didn't realize that tar's default
was to use those files or wanted to be explicit since
older tar commands have other defaults (the tape device).

> What other uses dup(3) might have?

the same as any other file system: it gives a file name
for a resource, making that resource usable in any program
that wants to open a file.

on unix the same need is often met by the lame idiom that
the file name - means standard input or output depending
on context.  /fd is a real file system and more general.

it's not something you need every day, but it's often crucial
when you do need it.  for example, look at the way it gets
used in in exportfs or page.

russ

Reply via email to