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

Re: ${(A)=xxx} - second go - now real bug.



On Jul 7,  7:32pm, Andrej Borsenkow wrote:
} Subject: ${(A)=xxx} - second go - now real bug.
}
}      [...] the WORD part *must* be converted to an array, for example
}      by using ${(AA)=...} to activate word splitting, when creating an
}      associative array.
} 
} Please, note the last sentence. It implies, that in case of array/hash
} assignment the word is treated as in array assignment - that is,
} ${(A)foo=bar baz} is basically the same as foo=(bar baz). At least, I
} find this natural and useful. And I have a feeling, that it was once
} so.

Read that sentence again, and note the word "converted."  It has *never*
been the case that ${(A)foo=bar baz} is the same as foo=(bar baz).

} I suggest changing it to the described. That is,
} 
} ${foo=bar} - the same as foo=bar (with blanks quoted, 'course)
} ${(A)foo=bar}, ${(AA)foo=bar} -
}              the same as foo=(bar)

I looked at this a bit when we had the last go-round about ${(A)foo=}.
The problem is that
	foo=(bar baz)
can be determined at lex time to be an array assignment by recognizing the
parens, whereas
	${(A)foo=bar baz}
lexes as a parameter expansion.  The lexer doesn't know that (A) is there,
and therefore can't break "bar baz" into words; it reads the entire ${...}
as a single string, which it is then up to the parameter expansion code to
interpret.  It has always been like this.

} A good question is, if we should do globbing in above cases. I dare to say,
} that it may be useful ...

Yes, it would, and that is in fact the reason that I looked into the issue
before.  It doesn't work for the same reason; the entire ${...} has already
been tokenized by the time it gets to the parameter code.

It *might* be possible to undo the tokenization and re-parse the string,
but that would involve invoking the lexer from the parameter code, which
I was not prepared to undertake.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



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