Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: syntactic question



On 11/21/2014 01:29 PM, Bart Schaefer wrote:


On Nov 21, 2014 12:25 PM, "Ray Andrews" <rayandrews@xxxxxxxxxxx <mailto:rayandrews@xxxxxxxxxxx>> wrote:
>
> I've always thought that all parsing systems work from the 'inside out'
> which is to say that (as with math) you 'do' the deepest parenthesis
> first, and then work outward.

Quotes aren't parens, there is no left and right so you can't nest them the way you are thinking of. With only a small number of exceptions, quoting in shells works left to right - once a quote is open, you obey only the rules of that type of quote until it closes again. Backslashes happen to have special meaning both inside and outside of quotes, but the details depend on which type of quote is active.

It's one of those things that's hard to get into one's DNA.

> In the same spirit, I'm expecting
> the substitution to do what it does following it's own rules and
> nevermind any quotations or anything else 'further out'.

Substitution occurs if there are no quotes or inside double quotes, but not inside single quotes. The rules are different when in double quotes, and documented.

Well, as long as the system works, and is understandable. I think my intuitions are forgivable, even if not correct. Bart, is there some readable doc that wraps it all up? In practice I get most all my problems solved now, but I despair of really understanding it, I tend to use trial and error.



Messages sorted by: Reverse Date, Date, Thread, Author