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

Re: Understanding why...

Interesting, when you say by default, is that an option that can be changed?

Thanks for that tidbit, any chance you know in the manual whereabouts it talks about this inner splitting and outer preservation?

Also (and I had tried to do this), is it possible to break out the nested expansions into their separate parts to see what is going on (via trace)?

I had tried that but it seemed that some zsh specific lines weren't showing (could have been because some of them where just variable sets, sans a typeset).

Thanks Much!

On 8/7/2017 7:36 PM, Bart Schaefer wrote:
On Mon, Aug 7, 2017 at 4:46 PM, Clint Priest <cpriest@xxxxxxxxxxxxxxxx> wrote:
I'll take an answer from someone here, but what I'd really like to find out
is if there is *some sort of 'set -x' functionality that would give me
verbose information *about what is going on.
No, there's no trace setting that would reveal the inner workings of
parameter expansion.  Your best bet is to look at the documentation,
e.g., search for the string "Rules" in "man zshexpn".

typeset-A LSC=(${(@s/=/)${(@s/:/)${LS_COLORS%:}}})

What it needed was the two @ flags.  I'd like to understand just what is
going on in each step of the expansion that required those two flags.
The short answer is that a nested expansion by default joins arrays on
the first character of $IFS and yields a scalar result.  The @ is
necessary to indicate that you want array-ness to be preserved.  It's
actually the OUTER ${...} that enforces joining on the INNER
expression, so in the above you only need the leftmost @ so that s/:/
isn't re-joined before s/=/ applies; but the second @ doesn't hurt.



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