Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Another expansion (substitution?) question
- X-seq: zsh-users 6391
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh users <zsh-users@xxxxxxxxxx>
- Subject: Re: Another expansion (substitution?) question
- Date: Wed, 9 Jul 2003 04:42:44 +0000
- In-reply-to: <545d6gkyk8e.fsf@xxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <545d6gkyk8e.fsf@xxxxxxxxxxxxxxxx>
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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author