bug-bash
[Top][All Lists]
Advanced

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

Re: nofork command substitution


From: Chet Ramey
Subject: Re: nofork command substitution
Date: Thu, 25 May 2023 10:08:03 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.11.0

On 5/25/23 6:29 AM, Koichi Murase wrote:
2023年5月24日(水) 22:27 Chet Ramey <chet.ramey@case.edu>:
[...]

Thanks for testing it.

Thank you for all the explanations and clarifications.

Both are valid, but don't get too fond of ${(command)} -- I'm going to
remove it in favor of people using ${ (command); } if they want a subshell.

Does that mean ${(command)} would be explicitly unsupported even
though {(command)} is allowed for the brace grouping?

It means that left paren is no longer one of the valid characters that
can follow `${'. If you want that, use a subshell command after a space.

Then, can I understand the grammar in the following way?  First, there
are two types of nofork command substitutions:

    ${ compound_list }
    ${| compound_list }

where `compound_list' is what is defined by EBNF in POSIX XCU 2.10.2.

You could always look at the shell grammar:

[...]

funsub:         DOLBRACE compound_list '}'
                          {
                            $$ = $2;
                          }
          |       DOLBRACE newline_list '}'
                          {
                            $$ = (COMMAND *)NULL;
                          }

OK, I haven't checked the grammar definition in the source code. I now
looked into parse.y, but it doesn't seem to be so clear to me what
would be the distinction among the variations of C = <space>, <tab>,
<newline>, `(', and `|' for `${C command; }' just by looking at the
definition. It seems to be processed on subst.c:6880 semantically.

It is, but that's not the code I'm talking about. Look at parse_comsub()
in parse.y and the places that call it.

The different characters that follow the open brace don't really have
any effect on the compound_list that gets parsed. They determine how the
parsed command is executed.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/




reply via email to

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