Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Solved, but now a new twist (was: Double Evaluation Question (not in FAQ))
- X-seq: zsh-users 10689
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: "zsh-users Mailinglist" <zsh-users@xxxxxxxxxx>
- Subject: Re: Solved, but now a new twist (was: Double Evaluation Question (not in FAQ))
- Date: Thu, 07 Sep 2006 18:53:14 +0100
- In-reply-to: Message from Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> of "Mon, 04 Sep 2006 11:24:05 PDT." <060904112405.ZM9160@xxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
Bart Schaefer wrote:
> On Sep 4, 10:43am, Com MN PG P E B Consultant 3 wrote:
> }
> } That is, if I have an assignment
> }
> } x='~linus ~steve'
> }
> } Is there also a simple solution, which expands $x to the home
> } directories of linus and steve, with spacing preserved?
>
> There's a complicated solution:
>
> setopt extendedglob
> print -r ${(j//)${(s/|/)~${x/(#b)( ##)/|$match|}}}
>...
> I'm actually a little surprised that this works -- I would have
> guessed that joining with (j//) took place before tilde expansion.
> But it seems to work as far back as backreferences (#b) do, so I
> guess it's safe to assume it'll keep working. (PWS, does something
> need to be added to the "Rules" section under "Parameter Expansion"?)
I think (though I haven't checked) that it's because of the prefork() in
multsub(), which gets called for subexpressions. This means that all
forms of $-style expansion as well as ` and ~/= expansion get handled at
each level at which a nested ${...} is processed. Yes, this probably
ought to be documented if anyone understood it well enough.
--
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author