From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: is variable with variable name possible?
Date: Tue, 5 Apr 2011 01:31:25 -0700 [thread overview]
Message-ID: <BANLkTikEaxNx42SAmpYGoPoxeq6LYWDbEg@mail.gmail.com> (raw)
In-Reply-To: <110404072617.ZM9904@torch.brasslantern.com>
The reply quoted below got hung up on my server for several hours
because a CentOS upgrade clobbered my sendmail configuration, which I
didn't notice immediately. Restored from backup (which is why I'm up
at 1:30am) and it finally went out. In the interim the discussion has
pointed out an omission I made.
On Mon, Apr 4, 2011 at 7:26 AM, Bart Schaefer <schaefer@brasslantern.com> wrote:
>
> You can also use ${somevar::=$(pwd)} anywhere that you'd reference the
> value of $somevar, including the no-op command:
>
> : ${somevar::=$(pwd)}
>
> : ${(As:/:)somevar::=$(pwd)}
The bit I forgot is that to get the effect desired in the original
message, you must add the (P) flag to each of the above, as in:
: ${(P)somevar::=$(pwd)}
: ${(PAs:/:)somevar::=$(pwd)}
As long as I'm expostulating I'll add that "somevar" can even be a
positional parameter, both with and without the (P) flag. E.g.
: ${(As:/:)1::=$(pwd)}
will splice the current directory hierarchy into the front of "$@".
next prev parent reply other threads:[~2011-04-05 9:02 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-04 13:37 zzapper
2011-04-04 13:48 ` Jérémie Roquet
2011-04-04 13:51 ` Jérémie Roquet
2011-04-04 14:13 ` zzapper
2011-04-04 14:26 ` Bart Schaefer
2011-04-05 8:31 ` Bart Schaefer [this message]
2011-04-04 14:06 ` Stephane Chazelas
2011-04-04 14:25 ` Mikael Magnusson
2011-04-04 16:28 ` Stephane Chazelas
2011-04-04 16:34 ` Mikael Magnusson
2011-04-04 20:50 ` Stephane Chazelas
2011-04-04 22:32 ` Mikael Magnusson
2011-04-05 18:39 ` Stephane Chazelas
2011-04-05 2:54 ` Aaron Davies
2011-04-05 3:54 ` Phil Pennock
2011-04-05 4:04 ` ZyX
2011-04-05 4:10 ` ZyX
2011-04-04 14:33 ` Jérémie Roquet
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=BANLkTikEaxNx42SAmpYGoPoxeq6LYWDbEg@mail.gmail.com \
--to=schaefer@brasslantern.com \
--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).