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    c...@case.edu    http://tiswww.cwru.edu/~chet/

Reply via email to