View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000581 | 1003.1(2008)/Issue 7 | Shell and Utilities | public | 2012-06-15 18:20 | 2019-06-10 08:55 |
Reporter | schweikh | Assigned To | ajosey | ||
Priority | normal | Severity | Objection | Type | Enhancement Request |
Status | Closed | Resolution | Accepted | ||
Name | Jens Schweikhardt | ||||
Organization | |||||
User Reference | |||||
Section | 2.10.2 Shell Grammar Rules | ||||
Page Number | 2325pp | ||||
Line Number | 73562-73564 (C082 this time :-) | ||||
Interp Status | Approved | ||||
Final Accepted Text | See 0000581:0001304 | ||||
Summary | 0000581: Grammar does not accept 'for i; do ...; done' | ||||
Description | The shell grammar does not accept 'for i; do ...; done' because it requires a 'linebreak' token after the 'i' token. However, existing practice of the most common shells is to accept it: $ echo 'for i; do echo $i; done' > tst.sh $ for sh in sh bash zsh ksh93 pdksh dash; do $sh -n tst.sh && echo $sh:ok; done sh:ok # FreeBSD's ash bash:ok zsh:ok ksh93:ok pdksh:ok dash:ok In order to standardize existing practice, it suffices to replace the "linebreak" with "empty or sequential_sep". This works without new conflicts. | ||||
Desired Action | in section 2.10.2 Shell Grammar Rules, change the for_clause in the indicated lines from for_clause : For name linebreak do_group | For name linebreak in sequential_sep do_group | For name linebreak in wordlist sequential_sep do_group ; to for_clause : For name do_group | For name sequential_sep do_group | For name linebreak in sequential_sep do_group | For name linebreak in wordlist sequential_sep do_group ; | ||||
Tags | tc2-2008 |
|
Although I think it is a good idea to standardize this commonly used variation, this grammar change would unfortunately require ksh93 to change. While ksh93 allows for name; do ... it does not allow for name;<newline>do ... which is obtained by putting ;<newline> for the sequential_sep instead of the more common semicolon or newline by themselves. |
|
If you go down in the grammar where "linebreak" and "newline_list" are defined on P2330, L73660-73665 are defined, you'll see that a "linebreak" is zero or more <newline>s (not one or more <newline>s). |
|
If my original proposal is considered problematic, a minimum grammar adjustment is adding "| For name ';' do_group" to the for_clause (no new conflicts as well). But note that all the other shells accept the grammar as originally proposed. Maybe it is an option for ksh93 to adapt and become more "standard" (or "non-standard", depending on your point of view)? How much of a burden on David or the ast-developers would it actually be? I tend to think the change makes the grammar more permissive along the lines of "you can always add a ; where a <newline> is". |
|
PS: Why do ksh93 (and 86+88) behave like this, and why does the grammar have this issue at all? The reason might be that ksh shared some code with the traditional Bourne shell which doesn't accept "for i; do" or "for i;<newline>do", but only the variants without semicolon [update: wrongly wrote <newline> at first]. |
|
Interpretation response ------------------------ The standard states that the shell grammar does not accept such usage, and conforming implementations must conform to this. However, concerns have been raised about this which are being referred to the sponsor. Rationale: ------------- Since all existing implementations either accept the enhanced grammar, or have patches available to fix it, a future version of this standard should relax this constraint. In particular, David Korn, author and maintainer of the Korn Shell, says: > From: David Korn > Subject: Re: Austin Group bug 0000581: Grammar does not accept 'for i; do ...; done' > Date: 29 June 2012 17:04:31 GMT+01:00 > > > Subject: Re: Austin Group bug 0000581: Grammar does not accept 'for i; do ...; done' > -------- > > I have no objections. I have already made the change and it is in the > beta version posted on our website. > > It was a one line change. > > David Korn > Notes to the Editor (not part of this interpretation): ------------------------------------------------------- Implement the change suggested in the Desired Action. |
|
Interpretation proposed 30 August 2012 for final 30 day review |
|
Interpretation approved 29 Mar 2013 |
Date Modified | Username | Field | Change |
---|---|---|---|
2012-06-15 18:20 | schweikh | New Issue | |
2012-06-15 18:20 | schweikh | Status | New => Under Review |
2012-06-15 18:20 | schweikh | Assigned To | => ajosey |
2012-06-15 18:20 | schweikh | Name | => Jens Schweikhardt |
2012-06-15 18:20 | schweikh | Section | => 2.10.2 Shell Grammar Rules |
2012-06-15 18:20 | schweikh | Page Number | => 2325pp |
2012-06-15 18:20 | schweikh | Line Number | => 73562-73564 (C082 this time :-) |
2012-06-15 21:27 | jilles | Note Added: 0001260 | |
2012-06-15 21:48 | Don Cragun | Note Added: 0001261 | |
2012-06-15 21:48 | Don Cragun | Note Edited: 0001261 | |
2012-06-16 09:05 | schweikh | Note Added: 0001262 | |
2012-06-16 09:08 | schweikh | Note Edited: 0001262 | |
2012-06-16 11:08 | s_mascheck | Note Added: 0001263 | |
2012-06-16 11:10 | s_mascheck | Note Edited: 0001263 | |
2012-06-20 18:10 | schweikh | Note Edited: 0001262 | |
2012-07-12 15:50 | nick | Interp Status | => --- |
2012-07-12 15:50 | nick | Note Added: 0001304 | |
2012-07-12 15:50 | nick | Status | Under Review => Interpretation Required |
2012-07-12 15:50 | nick | Resolution | Open => Accepted |
2012-07-12 15:50 | nick | Final Accepted Text | => See 0000581:0001304 |
2012-07-12 15:51 | nick | Tag Attached: tc2-2008 | |
2012-07-12 15:51 | nick | Interp Status | --- => Pending |
2012-08-30 09:17 | ajosey | Note Edited: 0001304 | |
2012-08-30 09:18 | ajosey | Interp Status | Pending => Proposed |
2012-08-30 09:18 | ajosey | Note Added: 0001359 | |
2013-03-29 08:01 | ajosey | Interp Status | Proposed => Approved |
2013-03-29 08:01 | ajosey | Note Added: 0001509 | |
2019-06-10 08:55 | agadmin | Status | Interpretation Required => Closed |