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

Re: bug in parameter expansion



On Thu, 08 Nov 2012 06:53:31 -0800
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Nov 7,  8:45pm, Peter Stephenson wrote:
> } It's happening because we look at the string "=*" and we tokenise
> } that to make patterns (such as the "*") active if it was in
> } quotes.  We tokenise the "=" the same as if it were a command line
> } argument.  I can't think of any occasion we'd want to do that if
> } we know it's *not* a command line argument: there's already a flag
> } for this, so the fix is simple.
> 
> This looks OK to me, but just to be sure I understand:  The flag
> you're talking about in this context is "sub" rather than
> "incmdpos"?  For those who may be attempting to learn the code,
> "incmdpos" really does mean "in the command position", e.g., the
> first word in the buffer or the first word after a separator such as
> ";" or "|", among other cases.

Yes, the flag I'm talking about is "sub".

I think you probably mean intpos rather than incmdpos; it says we're at
the start of the word, which is the only place you want to do =cmd
expansion.  However, I don't think the code even relies on that --- it
tokenises the "=" and relies on the fact that expansion later only looks
for an active =cmd expansion by checking the first character in the
argument.  Later still tokens are turned back to normal characters.

> The "sub" flag doesn't directly mean "not a command line argument"
> here, unless I'm mistaken?

Umm, yes and no.  No, it's not explicitly saying that.  However, it is
only used in a context where we're doing some substitution to a string
that isn't by itself a command line argument, though it may form part of
a command line argument later.

I think that's OK because at all such points the command line
tokenisation has taken place and it's the normal zsh behaviour that
substitution and globbing doesn't take place on substituted strings.  If
GLOB_SUBST is set, the (re)tokenisation takes place later, because we
don't expect to get tokens out of the early stages of expansion.

pws



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