Re: syntax error while parsing a case command within `$(...)'
From:
Koichi Murase
Subject:
Re: syntax error while parsing a case command within `$(...)'
Date:
Thu, 18 Feb 2021 01:34:59 +0800
2021年2月18日(木) 0:56 Robert Elz <kre@munnari.oz.au>:
> For a long time [...]
>
> [...] And it all has to be recursive,
> as $() cmdsubs can occur in the middle of words in the middle of other
> cndsubs.
Thank you for the historical story.
> Chet can explain more if he feels it is warranted, but I believe that even
> today, bash uses a very heuristic type of almost pretend to be a parser
> to deal with these things
Yes, that is done in `parse_comsub' in `parse.y' which I mentioned in
some earlier reply in this tree.
> None of the (current anyway) problems represent code that anyone trying
> to solve a real problem (as distinct from stressing the parser) would
> ever write, so one can understand a certain reluctance to spending a lot
> of time fixing things that only even happen in stress tests.
I actually doubt that it takes so much time to fix them... Have you
ever written a shell parser? Some time ago I have written a simple
shell parser mimicking the Bash behavior without thinking the details,
but it correctly parses all the command substitutions reported here.