Geoff Clare via austin-group-l at The Open Group wrote in
<Z9mxbpQol5ASbdDN@localhost>:
|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.
|
|> 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.
.. on a side note for the interested reader:
$ cat
cat: -: input file is output file
$ pkginfo -o $(command -v cat)
Package File
coreutils bin/cat
$ prt-get info coreutils
Name: coreutils
...
URL: https://www.gnu.org/software/coreutils/
...
So on Linux you better say "cat /dev/tty", as even
$ cat /dev/stdin
cat: /dev/stdin: input file is output file
$ ll /dev/stdin
lrwxrwxrwx 1 root root 15 Mar 17 18:15 /dev/stdin -> /proc/self/fd/0
does not work no more. That is really weird situation for cat(1)
on at least a terminal, and i am happy i am not alone with
expecting it to work.
--steffen
|
|Der Kragenbaer, The moon bear,
|der holt sich munter he cheerfully and one by one
|einen nach dem anderen runter wa.ks himself off
|(By Robert Gernhardt)