bug-bash
[Top][All Lists]
Advanced

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

Re: Parsing regression with for loop in case statement


From: Kerin Millar
Subject: Re: Parsing regression with for loop in case statement
Date: Thu, 11 Apr 2024 05:23:01 +0100

On Thu, 11 Apr 2024 15:07:14 +1200
Martin D Kealey <martin@kurahaupo.gen.nz> wrote:

> I can confirm that this changed between 4.4.23(49)-release and
> 5.0.0(1)-beta, which coincides with the parser being largely rewritten.
> 
> On Thu, 11 Apr 2024 at 12:51, <nbowler@draconx.ca> wrote:
> 
> > The POSIX shell grammar specifies that a newline may optionally appear
> > before the in keyword of a for loop.
> 
> 
> I don't see that at §2.9.4 "The for Loop" (
> https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_04_03)
> and I've never seen it in the wild.
> 
> But ... oh look, it's mentioned in §2.10.2 (
> https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_10_02
> ).
> 
> I wonder when that was added, and why?

I checked as far back as Issue 4 Version 2 (1994), which supports it. 
Specifically, it specifies the following two forms:

- for name linebreak do_group
- for name linebreak in wordlist sequential_sep do_group

Issue 6 additionally specifies the following form:

- for name linebreak in sequential_sep do_group

As a consequence of https://austingroupbugs.net/view.php?id=581, Issue 7 
additionally specifies the following form:

- for name sequential_sep do_group

Note that "linebreak" implies either a "newline_list" or nothing at all. With 
that in mind, here are some examples.

for var do :; done
for var in 1; do :; done
for var in; do :; done
for var; do :; done

-- 
Kerin Millar



reply via email to

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