[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: No error for missing semicolon before "then"
From: |
Chet Ramey |
Subject: |
Re: No error for missing semicolon before "then" |
Date: |
Fri, 6 Sep 2024 12:06:15 -0400 |
User-agent: |
Mozilla Thunderbird |
On 9/6/24 11:44 AM, Ulrich Mueller wrote:
Bash Version: 5.2
Patch Level: 32
Release Status: release
Description:
The following command does not error out, in spite of a
semicolon missing before "then":
$ if [[ x ]] then :; fi
Previous versions (e.g. 4.4.23) used to report an error:
bash: syntax error near unexpected token `then'
POSIX says that construct, even though the particular compound command
isn't part of the standard, should be accepted. Here's the report about
it, from a discussion about a broader topic:
https://lists.gnu.org/archive/html/bug-bash/2021-02/msg00140.html
All shells that implement [[...]] (bash/ksh/mksh/zsh) behave this way.
Bash changed in version 5.2.
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/
OpenPGP_signature.asc
Description: OpenPGP digital signature