Re: access the stdin of the parent process in a pipeline
From:
Chet Ramey
Subject:
Re: access the stdin of the parent process in a pipeline
Date:
Thu, 26 Mar 2020 14:54:55 -0400
User-agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.5.0
On 3/26/20 1:06 PM, Peng Yu wrote:
> On 3/25/20, Mike Jonkmans <address@hidden> wrote:
>> Apart from the redirection as part of a function declaration,
>> you can also use compund commands, as Chet already mentioned.
>> One hardly see these constructs in system scripts.
>> Though they are properly documented in the bash manual.
>>
>> Sometimes a 'subshell function' may be useful :
>>
>> f() ( ... )
>
> The above is a little strange as the `function` keyword does not work
> here without the `()` (as in the commented code below). I'd prefer to
> use the function keyword without the first `()` as the typical usage
> (`()` really doesn't do anything semantically).
The parser puts higher priority on the ( being the opening of a () to
complete the function definition than on being the opening of a subshell
command, and so the grammar requires the closing ).
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU address@hidden http://tiswww.cwru.edu/~chet/