Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: is variable with variable name possible?
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@xxxxxxxxxxxxxxxx> 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 "$@".
Messages sorted by:
Reverse Date,
Date,
Thread,
Author