On Sun, Aug 21, 2016 at 03:04:07PM -0400, Chet Ramey wrote: > The current text in redirection says: > > Bash handles several filenames specially when they are used in redirec- > tions, as described in the following table. If the operating system on > which bash is running provides these special files, bash will use them; > otherwise it will emulate them internally with the behavior described > below. > > The text for conditional expressions should say something similar.
Got it. > > No. If the OS provides /dev/fd and bash can detect it at build time, > process substitution, redirection, and conditional expressions will all > simply use the files the OS provides. There is no asymmetry. You are right. > > With this new contract how can the user write portable bash code which > > tests if > > a fd refers to a pipe? > > It's hard to say, given the existence of multiple incompatible > implementations of /dev/fd. It looks like SunOS is the oddball here, > but there might be other implementations that don't do the same thing > with stat(2). > > But why should bash override the semantics that an OS provides for > /dev/fd, resulting in differing behavior between the shell and other > utilities with the same pathname argument? For the benefit of the user. Currently bash behavior is different from the native test and ksh on sunos. What about a patch that switches to fstat only if such /dev/fd oddity was determined at configuration time? regards, Dmitry