Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Another expansion (substitution?) question
- X-seq: zsh-users 6392
- From: Vin Shelton <acs@xxxxxxxxxxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: Another expansion (substitution?) question
- Date: Wed, 09 Jul 2003 00:48:27 -0400
- Cc: Zsh users <zsh-users@xxxxxxxxxx>
- In-reply-to: <1030709044244.ZM21535@xxxxxxxxxxxxxxxxxxxxxxx> (Bart Schaefer's message of "Wed, 9 Jul 2003 04:42:44 +0000")
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Organization: EtherSoft, Inc
- References: <545d6gkyk8e.fsf@xxxxxxxxxxxxxxxx> <1030709044244.ZM21535@xxxxxxxxxxxxxxxxxxxxxxx>
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> writes:
> On Jul 8, 1:57pm, Vin Shelton wrote:
> } Subject: Another expansion (substitution?) question
> }
> } print -l ${(ou)${^$(all_dirs)}/$=~^*(N/:t)}
> } zsh: bad pattern: emacs* o*(N
>
> There are three problems here. One, you can't use an expansion that
> does not have braces (in this case "$=~^*") nested inside an expansion
> that does have braces. So you'd at least have to write (the following
> is not a working substitution):
>
> ${(ou)${^$(all_dirs)}/${=~^*}(N/:t)}
>
> However, problem two, globbing is not applied inside a nested expansion
> so your "(N/:t)" qualifiers are useless; and problem three, a slash in
> a brace-expansion is (as you found) a pattern substitution operator, as
> is two slashes, which is why doubling it didn't work; and three slashes
> in a row is probably being interpreted as substituting the empty string
> for all occurrences of the empty string.
>
> } x=( ${^$(all_dirs)}/$=~^*(N/:t) )
> } print -l ${(ou)x}
>
> The only way to reduce that to a one-liner is to use another subshell
> like so:
>
> print -l ${(ouf)"$(print -l ${^$(all_dirs)}/$=~^*(N/:t))"}
>
> This is probably not worth the expense of the extra fork and I/O. Stick
> with the two-liner using the temporary.
Thanks for the explanation, Bart.
- Vin
Messages sorted by:
Reverse Date,
Date,
Thread,
Author