[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: clarify behavior of /dev/fd redirections in docs

From: Chet Ramey
Subject: Re: clarify behavior of /dev/fd redirections in docs
Date: Tue, 12 Jul 2016 10:42:27 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

On 7/11/16 6:02 PM, Carl Edquist wrote:

> Bash Version: 4.3
> Patch Level: 46
> Release Status: release
> Description:
>     The docs say:
>         Bash handles several filenames specially when they are
>         used in redirections, as described in the following table:
>             /dev/fd/[fd]
>                 If [fd] is a valid integer, file descriptor [fd]
>                 is duplicated.
>     But in fact this is only true when HAVE_DEV_FD is undefined (see
>     redir.c lines 522-524).
>     Of course, when HAVE_DEV_FD is defined and the /dev/fd mechanism
>     for opening files is available, the idea is _similar_ to fd
>     duplication, but in fact there are important differences in the
>     semantics:

These semantic differences do exist with the Linux implementation of
/dev/fd, but not with other implementations.  The BSD and Mac OS X
versions, for instance, behave more or less as if they duplicate the
file descriptor.  For instance,

in particular fdesc_open(), which sets things up for dupfdopen(),
which duplicates a file descriptor.

I suppose it's worth saying something about how bash emulates the
files on systems that don't provide the feature themselves.

``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]