Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: In the tla completion function: "${(@P)var_cmd-*:FILE:_files}"

Haakon Riiser wrote:
> I was just browsing through the new completion function for tla
> in zsh 4.2.1, and I was wondering about the expression shown in
> the subject:
>   "${(@P)var_cmd-*:FILE:_files}"
> >From what I've read in the manual, I'd guess that the @ flag is
> a harmless bug that has no effect since $var_cmd is not an array,
> and that the P flag makes the expression expand to the expansion of
> the variable name contained in $var_cmd, if $var_cmd is defined;

First the value of $var_cmd is substituted by "P", and then the value of
the resulting variable (which is an array) is prevented from being
joined by "@". See rules 3 and 4 in the "Parameter Expansion" section of

> if $var_cmd is not defined, I'd expect the expansion to give the
> string after the '-':

$var_cmd is always defined to something of the form "cmd_*" on line 658.
I believe the P flag is evaluated before the - expansion, although I
don't see an explicit mention of it in the manpage. The variable named
by $var_cmd may or may not be defined, which is where the - expansion
comes into play.

I'm afraid I came up with many of my fancy substitutions by trial and
error ;-)

> Is this a bug in the completion file that has gone unnoticed
> because var_cmd has always been defined?

So no, I don't believe so. HTH,

Jason McCarty <bclg@xxxxxxx>

Messages sorted by: Reverse Date, Date, Thread, Author