From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: <138575260910160858nfc9444fr73e3328d98eac98a@mail.gmail.com> References: <138575260910160858nfc9444fr73e3328d98eac98a@mail.gmail.com> Date: Fri, 16 Oct 2009 09:52:52 -0700 Message-ID: Subject: Re: [9fans] dup(3) From: Russ Cox To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: text/plain; charset=UTF-8 Topicbox-Message-UUID: 884dcdd8-ead5-11e9-9d60-3106f5b1d025 On Fri, Oct 16, 2009 at 8:58 AM, hugo rivera 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