[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (read -r var) vs <(read -r var) behavior

From: Marcelo Azevedo
Subject: Re: (read -r var) vs <(read -r var) behavior
Date: Tue, 19 May 2015 11:23:49 +0300

what do you mean here by 'owns' the terminal ? and that in the second (subshell) example none of these things is true.
in '(command)'  is command attached to the terminal and in '<(command)' command is not?

On Tue, May 19, 2015 at 8:42 AM, Pierre Gaston <address@hidden> wrote:

On Mon, May 18, 2015 at 10:26 PM, Chet Ramey <address@hidden> wrote:
On 5/16/15 1:11 PM, address@hidden wrote:

> Bash Version: 4.3
> Patch Level: 30
> Release Status: release
> Description:
>         from interactive shell running cat < <(read -r var) prints:
>               bash: read: read error: 0: Input/output error
>         on the other hand:
>                 (read -r var)   reads chars from terminal stdin
> Repeat-By:
>          cat < <(read var)

I'm not sure what the question is here.  The two constructs are totally
different in effect and implementation.  The error comes because the
process substitution is run asynchronously, in the same process group as
the calling shell (though exactly which pgrp doesn't matter), and the
`cat' process runs in a different process group and `owns' the terminal.

In the second (subshell) example, none of these things is true.

``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

The question really is (I discussed this with him on IRC) why can you do:

$ cat <(read var </dev/tty;echo $var)

but not:

$ cat < <(read var </dev/tty;echo $var)
bash: read: read error: 0: Input/output error


reply via email to

[Prev in Thread] Current Thread [Next in Thread]