[Top][All Lists]

[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: Wed, 24 Feb 2021 12:08:50 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.8.0

On 2/23/21 7:31 PM, Mike Jonkmans wrote:
On Tue, Feb 23, 2021 at 04:33:44PM -0500, Chet Ramey wrote:
On 2/22/21 8:11 AM, Mike Jonkmans wrote:


It seems some things are missing in the bash manual.
Notably definition of command and placements of coproc- and function-definition.

The section 'SHELL GRAMMAR' describes:
- simple-command
- pipeline
- list
- compound-command
- coproc
- function-definition

These are basically the `command' productions from the grammar. The
exception is `list', and it's there because it would be strange for
the reader if it were presented before simple commands and pipelines,
which users are more likely to encounter, even though a complete
command is technically a list.

It is mostly recursive, so you have to start somewhere.

Sure. We start with lists. That's just not something that will resonate
with a reader.

Your reasoning is understandable. Start with what the reader knows.
Though the readers are likely to be familiar with grammars/rules/start symbols.

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.

Because 'command' is not described, a reader might think that all these items
are commands.

Simplified, a pipeline is:
        [ ! ] command1 [ | command2 ]

A list is a sequence of pipelines separated by ;, &, &&, or ||
and optionally terminated by ;, & or NL.

Within the list description, the and-list and or-list are described as:
        and-list: command1 && command2
        or-list: command1 || command2
Though the text says that and/or-lists are sequences of pipelines
(separated by && or ||).

`command1' and `command2' are meta-notation, not a grammar production.

I know. It is just as the man page describes it.
The numbering is quite handy for referring in the text.

That is slightly inconsistent.
Not really.

A pipeline can be reduced to a command.
In a sense, yes, depending on your definition of `command'.

That is the point. The documentation never describes what a 'command' is.
The inconsistency comes when you try to follow the documentation's
use of 'command'. It is only in the words, not in the real grammar of course.

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 do think I'll change the pipeline description to use `command1' instead
of `command', though.

In that case, the and/or list should read:
        and-list: pipeline1 && pipeline2
        or-list: pipeline1 || pipeline2

No, it really shouldn't.

You're right. These pipelines should be lists.

No. An and-or list is

        and-or: and-or && pipeline
              | and-or || pipeline
              | pipeline

It's left-associative.

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