bug-bash
[Top][All Lists]
Advanced

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

Re: Shell Grammar man page


From: Chet Ramey
Subject: Re: Shell Grammar man page
Date: Thu, 25 Feb 2021 18:28:34 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.7.1

On 2/25/21 10:13 AM, Mike Jonkmans wrote:

Readers are likely to be familiar with simple commands and pipelines,
especially the ones who primarily use interactive shells. I disagree that
the average reader is likely to be familiar with grammars.

Aren't grammars taught already in primary school? It is in the Netherlands.

Ha, no. Formal grammars? Rudimentary English grammar, maybe.

Starting with 'Statements' might be an option.

Maybe. Or a POSIX-like description that says a command can be a

simple command
list
pipeline
compound command
function definition
coproc

just like the sections in the SHELL GRAMMAR section.

So where would you suggest changes? I'd argue that the use of `command' in
the simple commands section is quite clear. I'd also argue that everyone
understands what `the last command in a pipeline' means, or `commands in a
list', and that those are more descriptive than `pipeline elements' or
`list elements'.

I agree that the usage of 'command' is clear in these cases.
But these commands are different things.
The command in pipelines might be better described as compound-command.

No. A simple command may be a pipeline element (and most often is, given
how the shell is usually used). Compound commands are as described in the
manual, basically equivalent to the shell_command production in the bash
grammar.

May I also suggest to make it more clear that coprocesses and
function-definitions are compound-commands also?
The indentation of these differ from the preceding while/if/etc.

They are not, if you're being formal about it. They can't be used all
the places where a compound command (shell_command) can be, and they
take compound commands as pseudo-arguments, so they have to be
separate productions.

The description of Coprocesses uses the words 'shell command'.
That looks like it came from shell_command in parse.y and is actually
a compound-command without coproc and funcdef (limited-compound-command?).

That's where the term itself might have come from (probably not), but a
coproc can also be a simple command.

The 'command' in 'coproc [NAME] command [redirections]' is also
a limited-compound-command.

No, it's not. Maybe the thing to do is to say that the command in a coproc
can be a simple command or a compound command (shell_command). It's really
only the introductory sentence in the coproc description that needs to be
changed.

Maybe just mention in the text that the compound-command is limited
or leave coproc/funcdefs outside of compound-command (but i think that would
need more mentioning).

The compound command description is accurate. I think you're trying to make
a compound comand more than it is.


sidenote: parse.y has:
  - 'shell_command' which has for/while/if/etc. constructs;
  - 'command' (shell_command + coproc + funcdef)
        which is equivalent to compound-command.

No. It's not. Even the POSIX grammar definition makes that clear.

--
``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]