bug-bash
[Top][All Lists]
Advanced

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

Re: No form commsub if last token ends with & or ;


From: Chet Ramey
Subject: Re: No form commsub if last token ends with & or ;
Date: Mon, 19 Jun 2023 14:15:33 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.12.0

On 6/18/23 4:59 AM, Grisha Levit wrote:
On Sunday, May 28, 2023, Grisha Levit <grishalevit@gmail.com> wrote:

Missing final `;':

"$BASH" --pretty-print <<< $'${ : \;;}'
${ : \; }


The latest set of fixes to this code solves these cases but others  have
issues:

$ bash --pretty-print <<<$'${ : \;;\n}'
${ : \; }
$ bash --pretty-print <<<$'${ : \;\n\n}'
${ : \; }
$ bash --pretty-print <<<$'${ : \&;\n}'
${ : \& }
$ bash --pretty-print <<<$'${ : \&;\n\n}'
${ : \& }

I think it might be ok to just have print_comsub handle adding the final
semicolon when needed instead of trying to add it after the fact in
parse_comsub?

I'll think about it. The advantage of doing it in parse_comsub is that
the parser has access to the token history, instead of having to intuit
it lexically. Along the lines of what Martin Kealey said, it's easy to
output a newline if the last token the parser read before the closing `}'
was a newline, and that solves this problem.

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




reply via email to

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