On 3/20/25 12:51 PM, Geoff Clare via austin-group-l at The Open Group wrote:
Chet Ramey wrote, on 20 Mar 2025:On 3/20/25 7:04 AM, Geoff Clare via austin-group-l at The Open Group wrote:Chet Ramey wrote, on 18 Mar 2025:On 3/18/25 1:46 PM, Geoff Clare via austin-group-l at The Open Group wrote: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.This issue has only just been raised with the POSIX developers, so unless you expect them to be capable of time travel, you can't expect it to have been noted in the standard.I don't buy that. The example Lawrence found in the rationale has been there since at least 1992. The standard developers were certainly aware of the issue, even if they did not use the exact example we're using here. Maybe something more than an example in the rationale would have been useful.How does that example show that they were aware of any of the recently raised issues in this area? All it says is that: exec < /etc/passwd cat <&0 & wait produces no output, and that's true for ksh88, which is presumably what they tested it with at the time.
Sorry, I meant they were aware of the 0<&0 issue and whether it counts as
an explicit redirection. They simply used a different example than
echo hello | { cat <&0 & wait; }
which should have the same order of operations as the one in the rationale,
at least from the perspective of the `cat' subshell, but produces different
output.
But we can agree not to get distracted by it if you have a different
question.
I'll have to look at it after bash-5.3 is released. To be clear, this means that the implicit redirection from /dev/null takes place before any redirections are processed, right? And a secondary question is whether or not a pipe counts as an explicit redirection.The difference is specifically for the commands at the top of this last quote, or the following variant which doesn't need you to observe that cat is waiting for input: $ echo hello | /usr/xpg4/bin/sh -c 'cat 0<&0 & wait' $ echo hello | ksh93u+m -o posix -c 'cat 0<&0 & wait' $ echo hello | mksh -c 'cat 0<&0 & wait' $ echo hello | dash -c 'cat 0<&0 & wait' $ echo hello | bash -o posix -c 'cat 0<&0 & wait' hello which, coincidentally, is pretty much the same situation as the example in the rationale.
So "yes", then. But then how about my example from above, where the only
change is that the shell is the parent of both processes? How do you
differentiate between the two from the process forked to run `cat <&0'?
Shouldn't the piping happen before the redirection?
--
``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/
OpenPGP_signature.asc
Description: OpenPGP digital signature
