On 3/18/25 1:11 PM, Harald van Dijk via austin-group-l at The Open Group wrote:
On 18/03/2025 14:45, Geoff Clare via austin-group-l at The Open Group wrote:
Those shells also print "hello" without the redirection:
$ sh -c 'set +m; echo hello | { cat & wait; }' # sh here is bash
hello
$ ksh93u+m -c 'set -o posix; set +m; echo hello | { cat & wait; }'
hello
So this has nothing to do with 0<&0 - it's a non-conformance with the
non-job-control asynchronous AND-OR list requirements in some
circumstances.
Huh, so they do.
bosh also does the same.
If bash, ksh, bosh all do the same thing, but POSIX specifies another
thing, is there a rationale somewhere explaining why?
Yes, if the two baseline shells the standard used behave differently than
the standard specifies, there is usually some mention of it in the
rationale. POSIX did a fair amount of inventing, but always explained why.
But still, in bash, 0<&0 really does have this effect. Here is a better
test case:
$ bash -o posix -c 'cat & wait'
<immediately exits>
$ bash -o posix -c 'cat 0<&0 & wait'
<waits for stdin>
Because we just decided, at this moment, that 0<&0 is not an explicit
redirection.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU [email protected] http://tiswww.cwru.edu/~chet/