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

Re: Understanding why...



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