[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: Tue, 23 Feb 2021 16:33:44 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.7.1

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.

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.

That is slightly inconsistent.

Not really.

A pipeline can be reduced to a command.

In a sense, yes, depending on your definition of `command'.

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

No, it really shouldn't.

The bash grammar is a little messier than that POSIX grammar in
but it's basically the same.

Where are you trying to go with this?

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