[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: syntax error while parsing a case command within `$(...)'
From: |
Chet Ramey |
Subject: |
Re: syntax error while parsing a case command within `$(...)' |
Date: |
Mon, 15 Feb 2021 10:01:09 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 |
On 2/13/21 5:21 PM, Robert Elz wrote:
| $ bash -c ': $(case x in x) esac)'
This is a well known bash deficiency. When parsing command substitutions
it (approximately) simply counts (unquoted) parentheses to find the end.
Anything with a valid closing ')' but with no opening '(' confuses it.
The situation's not that dire. The bash command substitution parser handles
the majority of these cases (heh) without a problem, including the ones in
the POSIX test suite.
It's only the really obscure cases like this one (esac after right paren
ending a pattern list) that it doesn't handle. I don't expect that to be a
problem to fix.
This problem has been known for a LONG time, without it being fixed.
This particular example has never been reported. I infer from that that
it's not a widely used syntax variant.
Fixing it would take major work in the parser, so the chances of it
happening are not all that great.
Yes, that's the problem. Yacc-based parsers are not easily re-entrant, and
it takes major work to make them so. Bison is supposed to be able to
generate `pure' parsers, but I haven't looked at that for a long time. (I
tried it once, years ago, but there were problems with making it work.)
--
``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/
- Re: syntax error while parsing a case command within `$(...)', (continued)
- Re: syntax error while parsing a case command within `$(...)', Robert Elz, 2021/02/14
- Re: syntax error while parsing a case command within `$(...)', Stephane Chazelas, 2021/02/14
- Re: syntax error while parsing a case command within `$(...)', Robert Elz, 2021/02/14
- Re: syntax error while parsing a case command within `$(...)', Oğuz, 2021/02/14
- Re: syntax error while parsing a case command within `$(...)', Chet Ramey, 2021/02/15
Re: syntax error while parsing a case command within `$(...)', Oğuz, 2021/02/13
Re: syntax error while parsing a case command within `$(...)', Lawrence Velázquez, 2021/02/13
Re: syntax error while parsing a case command within `$(...)',
Chet Ramey <=
Re: syntax error while parsing a case command within `$(...)', Dale R. Worley, 2021/02/14
- Re: syntax error while parsing a case command within `$(...)', Oğuz, 2021/02/14
- Re: syntax error while parsing a case command within `$(...)', Lawrence Velázquez, 2021/02/14
- Re: syntax error while parsing a case command within `$(...)', Dale R. Worley, 2021/02/16
- Re: syntax error while parsing a case command within `$(...)', Lawrence Velázquez, 2021/02/17
- Re: syntax error while parsing a case command within `$(...)', Dale R. Worley, 2021/02/17
- Re: syntax error while parsing a case command within `$(...)', Lawrence Velázquez, 2021/02/18
Re: syntax error while parsing a case command within `$(...)', Eli Schwartz, 2021/02/14