2021-06-28 20:01:03 +0700, Robert Elz: [...] > [email protected] said: > | On the zsh mailing list, where the issue was initially brought up by > | Vincent, there was also the mention that EBADF error was explicitly > | ignore as a special case, as some systems have or used to have > | non-usable /dev/null, > > Weird, just out of interest, which are those? And do any of them > claim to be (any facsimile of) posix conformant?
No idea, that was a vague recollection of one of zsh's maintainers. One can imagine it being the case on some embedded systems or minimalist container / chroot, like ones created by non-priviledged users. I'd call them pathological corner cases though, probably not worth taking into account. > | so users were using >&- instead to silence output. > > | If stdout is closed, one could argue the user explicitly wants the > | output to be discarded. > > if a utility is invoked with any of stdin/out/err closed then what happens > is very explicitly unspecified in POSIX. All good points. My Solaris test cases corrected to use EPIPE instead of EBADF: $ (trap "" PIPE; sleep 1; /usr/xpg4/bin/sh -c 'grep root /etc/passwd; echo "$?" >&2') | : 0 $ (trap "" PIPE; sleep 1; /bin/sh -c 'grep root /etc/passwd; echo "$?" >&2') | : 0 $ (trap "" PIPE; sleep 1; /bin/sh -c 'pwd; echo "$?" >&2') | : 0 -- Stephane
