Re: dash bug: double-quoted "\" breaks glob protection for next char

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

 



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:

  "${x#"${y-*}"''}"

When the parser has processed

  "${x#"${y-

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

  "${x#"${y-*}

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!

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



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux