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: Chet Ramey
Subject: Re: Parsing regression with for loop in case statement
Date: Sat, 13 Apr 2024 12:51:04 -0400
User-agent: Mozilla Thunderbird

On 4/10/24 8:51 PM, nbowler@draconx.ca wrote:

Bash Version: 5.2
Patch Level: 21
Release Status: release

Description:
The POSIX shell grammar specifies that a newline may optionally appear
before the in keyword of a for loop.
        [...]
However, if the exact same loop is placed within the body of a case
statement, current versions of bash exit with a syntax error:

Thanks for the report. This came in in 2017 with better support for POSIX
grammar rule 6, which is concerned with returning IN as the third word of
a case or for command. The idea is that you need to keep track of whether
or not you're returning an IN for a case command (in which case you enter
a case pattern list state and can't perform alias expansion or return
reserved words unless ESAC is the next token) or for a for command. The
state management gets fooled by the multiple newlines; the parser needs
more context.

Chet
--
``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/

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


reply via email to

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