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, https://github.com/freebsd/freebsd/blob/master/sys/fs/fdescfs/fdesc_vnops.c; 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 c...@case.edu http://cnswww.cns.cwru.edu/~chet/