Chet Ramey <chet.ramey <at> case.edu> writes:
> > $>cmd_print () { mkfifo zout ; (tee zout &); cat zout ; rm zout; }
> > $>printf 'hello\n' | cmd_print
>
> When job control is not active, Posix requires that a command run in the
> background with `&' behave as if its standard input were /dev/null in the
> absence of any explicit redirection. Bash counts a pipe directly into
> such a command as one such redirection, but not the pipe into the shell
> function.
Actually, POSIX states this:
"The standard input for an asynchronous list, before any explicit redirections
are performed, shall be considered to be assigned to a file that has the same
properties as /dev/null. If it is an interactive shell, this need not happen.
In all cases, explicit redirection of standard input shall override this
activity."
In other words, the presence or absence of job control is not the best criteria
for whether to do the /dev/null redirection. The initial /dev/null redirection
MUST occur in non-interactive shells, even if job control is active. However,
for interactive shells, it is still acceptable to use the presence of job
control as a hook for deciding whether to perform the redirection.
--
Eric Blake
_______________________________________________
Bug-bash mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-bash