[Top][All Lists]

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

[Help-bash] operator contexts: operator tokens vs control operators

From: Michael Convey
Subject: [Help-bash] operator contexts: operator tokens vs control operators
Date: Tue, 14 Jul 2015 20:10:49 -0700

I'm having difficulty reconciling the distinction between tokens that are
classified as operators according to shell grammar and control operators.
The bash manual has the following definition:

Control operator: A token that performs a control function. It is a newline
or one of the following:
‘||’, ‘&&’, ‘&’, ‘;’, ‘;;’, ‘|’, ‘|&’, ‘(’, or ‘)’

The POSIX standard, section 2.10 Shell Grammar, lists only the following
that correspond to operator token identifiers:
‘||’, ‘&&’, ‘;;’, ‘<<’, ‘>>’, ‘<&’, ‘>&’, ‘<>’, ‘<<-‘, ‘>|’,

​a complete list is not provided by the POSIX standard,
there are eight instances of the term “control operator” as follows:

2.9.1 Simple Commands: A "simple command" is a sequence of optional
variable assignments and redirections, in any sequence, optionally followed
by words and redirections, terminated by a control operator.
2.9.2 Pipelines: A pipeline is a sequence of one or more commands separated
by the control operator '|'.
2.9.3 Lists: If a command is terminated by the control operator <ampersand>
( '&' ), the shell shall execute the command asynchronously in a subshell.
2.9.3 Lists: The control operator "&&" denotes an AND list.
2.9.3 Lists: The control operator "||" denotes an OR List.
2.9.4 Compound Commands: Each of these compound commands has a reserved
word or control operator at the beginning, and a corresponding terminator
reserved word or operator at the end.
2.9.4 Compound Commands: The semicolon shown here is an example of a
control operator delimiting the } reserved word.
2.9.4 Compound Commands: The control operator ')' terminates a list of
patterns corresponding to a given action.

In the preceding list,
​the first 2.9.4 ​
implies that that a control operator
​can be
a reserved word. However, some of the control operators listed in the bash
manual definition above are, according to POSIX shell grammar, associated
with operator token identifiers.
​Also, POSIX shell grammar implies that operator tokens cannot also be
reserved word tokens. ​
Please help me
distinguish between operator token identifiers and reserved words that may
both be control operators. Also, please help me reconcile these
classifications to the token categories in POSIX shell grammar and the
control operator definitions in the POSIX standard and in the bash manual.

reply via email to

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