On 8/23/16 5:00 PM, Helmut Karlowski wrote: > Now extending Pierre's example: > > exec 3>tb.err > echo 3>&1 > >(echo 1 1>&3) > echo +++++ > cat tb.err > echo ----- > echo 3>&1 > >(echo 11 1>&3) > echo +++++ > cat tb.err > echo ----- > echo > >(echo 2 1>&3) 3>&1 > echo +++++ > echo ----- > cat tb.err > echo > >(echo 3 1>&3) > echo +++++ > cat tb.err > echo ----- > wait > > I get in bash:
Strange. I get +++++ 1 ----- +++++ 11 ----- +++++ ----- 2 +++++ 2 3 ----- on Mac OS X and RHEL 6. I'm not sure why the last redirection (the one with just process substitution and not 3>&1) doesn't cause the file to be truncated, or the file pointer to be adjusted, but the trace is the same in all cases. > > 1 > > in ksh93 (where > >() does not work anyway, at least on cygwin): This doesn't work on any ksh93, whether /dev/fd and process substitution are available or not. > in zsh (sometimes, sometimes it prints nothing): I speculate that this has to do with something that zsh does to force appending, whether that's lseek or something else, other than the fact that zsh doesn't seem to use /dev/fd at all (I think it just straight uses pipes). Bash doesn't do anything special with tb.err after opening it, just manipulates the file descriptors with dup2 and fcntl. Chet -- ``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/