On 02/03/2018 17:33, Herbert Xu wrote:
On Fri, Mar 02, 2018 at 05:05:46PM +0100, Harald van Dijk wrote:

But in "${x+${y-}''}", the ' is the literal ' character. In "${x#${y-}''}",
the ' is a quote character. This part is hard. If the above is done simply
using another local variable, then the parse of the nested ${y-} would
clobber that variable.

I don't see why that's hard.  You just need to remember whether
you're in a pattern context (i.e., after a %/%% or #/##).  If you
are, then you need to go back to basesyntax instead of dqsyntax
until the next right brace.

Let me slightly modify my example so that the effect becomes different:


When the parser has processed


would the state be "in a pattern context", or "not in a pattern context"?

If the state is "in a pattern context", how do you prevent the next * from being taken as unquoted? It should be taken as quoted.

If it stores "not in a pattern context", and the parser is processing the last character in


how can it reset the state to "in a pattern context"? Where could this state be stored?

With arbitrarily deep nesting of variable expansions, I do not see how you can avoid requiring arbitrarily large state, which gets difficult with dash's non-recursive parser. Mind you, I do hope I'm missing something obvious here!

Harald van Dijk
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to