* Misc. musings on shell grammar (plus a bug?)
@ 2003-06-15 20:27 Bart Schaefer
2003-06-16 9:05 ` Peter Stephenson
0 siblings, 1 reply; 2+ messages in thread
From: Bart Schaefer @ 2003-06-15 20:27 UTC (permalink / raw)
To: zsh-workers
Musing about the grammar documentation, actually, not about the grammar
itself.
The grammar (ignoring redirections) as described by the corresponding
section of the manual is roughly
simple ::= wordlist | modifier simple
pipeline ::= simple PIPE pipeline | simple
coprocess ::= "coproc" pipeline
sublist ::= pipeline JOIN sublist | pipeline
clist ::= sublist SEP clist | sublist
list ::= clist SEP | <empty>
complex ::= "(" clist ")" | "{" clist "}" | "[[" exp "]]" |
if | for | while | until | repeat | case | select | time
[Grammars of structured commands omitted for brevity.]
I first note the omission of "((math))" here. There should at least be
a mention of that in the grammar section.
Another note is that the placement of at least "[[exp]]" and "time" is
misleading. "[[exp]]" behaves like a "list" in that no separator is
needed when it appears before a keyword in a structured command, and
"time" belongs somewhere between "pipeline" and "sublist".
A more accurate representation of the grammer would be
simple ::= wordlist | modifier simple
complex ::= "(" clist ")" | "{" clist "}" | "[[" exp "]]" | math |
if | for | while | until | repeat | case | select
statement ::= simple | complex
pipeline ::= statement PIPE pipeline | statement
job ::= pipeline | <empty>
coprocess ::= "coproc" job
timeline ::= "time" job
process ::= pipeline | coprocess | timeline
sublist ::= process JOIN sublist | process
nonempty ::= sublist SEP nonempty | sublist
clist ::= nonempty | <empty>
list ::= clist SEP | complex | <empty>
math ::= "((" <math expression> "))"
And I have no idea why I just spent more than an hour working that out
except that perhaps it'll give somebody else (or me, when I reread it
later) some ideas for how to improve the documentation. Even so, it's
still not quite right because some combinations of "time" and "coproc"
that are valid (though not very useful) can't be derived.
Now for the "bug" -- this is 4.0.6, but 4.1.1-testX behaves the same:
schaefer[501] if false & then echo oops & fi
[2] 20011
[2] + exit 1 false
oops
[2] 20012
[2] + done echo oops
I suppose this makes sense -- this test would be false only if "false"
could not be backgrounded, e.g., fork failure?
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Misc. musings on shell grammar (plus a bug?)
2003-06-15 20:27 Misc. musings on shell grammar (plus a bug?) Bart Schaefer
@ 2003-06-16 9:05 ` Peter Stephenson
0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2003-06-16 9:05 UTC (permalink / raw)
To: zsh-workers
Bart Schaefer wrote:
> Musing about the grammar documentation, actually, not about the grammar
> itself.
I'm hoping to get 4.1.1 and 4.0.7 out pretty soon, except I'm rather
busy, but I don't suppose this is urgent.
> Now for the "bug" -- this is 4.0.6, but 4.1.1-testX behaves the same:
>
> schaefer[501] if false & then echo oops & fi
> [2] 20011
> [2] + exit 1 false
> oops
> [2] 20012
> [2] + done echo oops
>
> I suppose this makes sense -- this test would be false only if "false"
> could not be backgrounded, e.g., fork failure?
This is correct: from The Open Group Base Specifications Issue 6
IEEE Std 1003.1, 2003 Edition:
Exit Status
The exit status of an asynchronous list shall be zero.
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070
**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential
and/or privileged material.
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by
persons or entities other than the intended recipient is
prohibited.
If you received this in error, please contact the sender and
delete the material from any computer.
**********************************************************************
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-06-16 9:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-15 20:27 Misc. musings on shell grammar (plus a bug?) Bart Schaefer
2003-06-16 9:05 ` Peter Stephenson
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).