zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Clint Priest <cpriest@zsh-users.rxv.me>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: Understanding why...
Date: Mon, 7 Aug 2017 17:36:22 -0700	[thread overview]
Message-ID: <CAH+w=7YoRg7whrUAdCwMsbiUPFJnJMT5nvq_SdOO7BZd7ocdCg@mail.gmail.com> (raw)
In-Reply-To: <20b0b8aa-6db5-9b61-961c-b9a7ba10f34d@zsh-users.rxv.me>

On Mon, Aug 7, 2017 at 4:46 PM, Clint Priest <cpriest@zsh-users.rxv.me> 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.


  reply	other threads:[~2017-08-08  0:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-07 23:46 Clint Priest
2017-08-08  0:36 ` Bart Schaefer [this message]
2017-08-08  1:26   ` Clint Priest
2017-08-08  5:25     ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7YoRg7whrUAdCwMsbiUPFJnJMT5nvq_SdOO7BZd7ocdCg@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=cpriest@zsh-users.rxv.me \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).