Sorry, I didn't cc the list on this one (the default reply-to settings
don't include it).
--- Begin Message ---
On 3/18/25 1:46 PM, Geoff Clare via austin-group-l at The Open Group wrote:
Harald van Dijk wrote, on 18 Mar 2025:
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?
I can't think of any reason they would deliberately behave that way, so
unless one of the shell authors can come up with some justification, I'm
going to consider it a bug.
Oh, stop. If this behavior predates the standard, and is present in the two
baseline shells the standard used, it's a deviation from existing practice
by POSIX and should have been noted. Otherwise, it's little more than
"you're not conformant with this requirement we invented." Which is fine,
not the first time, but at least be forthright about it.
(Someone should check ksh88 and verify or disprove my assumption that ksh88
behaved the same as ksh93. I don't have easy access to a Solaris vm right
now.)
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>
Okay, looks like we'll need Chet's input on this part.
I gave it: until just now, 0<&0 was unspecified and considered an
`explicit' redirection that overrode the implicit redirection from
/dev/null.
The original language, from 1992, is "In all cases, explicit redirection
of standard input shall override this activity." Bash interpreted that to
mean that the implicit redirection of didn't happen.
--
``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/
--- End Message ---