In the following snippet, I expect the two ls' to give the same output. However, it appears the process substitution's temporary file sometimes vanishes for the second. Can someone explain why and whether this is the desired behavior or not?
A Linux (2.6.27.6) VM in a QEMU says this: # moo() { ls -l "$1"; ls -l "$1"; }; moo >(true) l-wx------ 1 root root 64 Aug 2 14:00 /dev/fd/63 -> pipe:[245] ls: cannot access /dev/fd/63: No such file or directory A Linux (2.6.32-5-amd64) machine says this: # moo() { ls -l "$1"; ls -l "$1"; }; moo >(true) l-wx------ 1 devel devel 1 Aug 2 16:03 /dev/fd/63 -> pipe:[527968] l-wx------ 1 devel devel 1 Aug 2 16:03 /dev/fd/63 -> pipe:[527968] My Mac says this: # moo() { ls -l "$1"; ls -l "$1"; }; moo >(true) prw-rw---- 0 lhunath staff 0 2 Aug 15:55 /dev/fd/63| prw-rw---- 0 lhunath staff 0 2 Aug 15:55 /dev/fd/63| And the latter two break again when I toss a (true) inbetween the two ls': # moo() { ls -al "$1"; (true); ls -al "$1"; }; moo >(true) l-wx------ 1 devel devel 1 Aug 2 16:06 /dev/fd/63 -> pipe:[528022] ls: cannot access /dev/fd/63: No such file or directory # moo() { ls -al "$1"; (true); ls -al "$1"; }; moo >(true) prw-rw---- 0 lhunath staff 0 2 Aug 16:07 /dev/fd/63| ls: /dev/fd/63: Bad file descriptor Surely neither case where the FD can no longer be accessed or its file has disappeared can be correct behavior?
smime.p7s
Description: S/MIME cryptographic signature