On 9/10/25 4:50 PM, Martin Jambon wrote:

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

Description:

    I wrote a script in which I accidentally omitted a semicolon after a
    ]] and before a then. It didn't work for a colleague of mine using
    another version of Bash.

    Expectation: I expect a syntax error in the absence of a semicolon
    or a newline between the closing brackets and the then.

Thanks for the report. The bash-5.2 and later behavior is correct, and
consistent with the behavior of other shells that implement [[...]].

It was changed in 2021 as the result of

https://lists.gnu.org/archive/html/bug-bash/2021-02/msg00140.html

The POSIX rule this follows is

"When the TOKEN is exactly a reserved word, the token identifier for that
reserved word shall result. Otherwise, the token WORD shall be returned.
Also, if the parser is in any state where only a reserved word could be the
next correct token, proceed as above."

There was a discussion about this just last week. The current version of
the man page says that reserved words are recognized as such if they are
the first word following a reserved word except case, for, select, or in.

Chet

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    [email protected]    http://tiswww.cwru.edu/~chet/

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to