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

Re: Unexpected foo==bar errors



On Sun, Feb 7, 2016 at 8:16 PM, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Feb 7,  4:57pm, Mikael Magnusson wrote:
> }
> } I always thought of EQUALS expansion as a form of globbing; should it
> } be enabled in these contexts even though regular globbing isn't?
>
> It's expansion, like with a leading tilde, not globbing, so GLOB_ASSIGN
> doesn't apply here at all.

Ah yes, you're right; I also get errors if I do
% tar tf ~blurg <tab>
_tar:70: no such user or named directory: blurg

> MAGIC_EQUAL_SUBST has never controlled expansion occurring in parameter
> assignments, it only controls whether expansion occurs in normal command
> arguments that LOOK LIKE assignments.
[...]
> } _tar:70 is
> } tf=${~words[3]}
>
> Ooh, that's a fun one: (foo) is being taken as glob qualifiers, which is
> a larger problem in this case than the expansion of "=".  Then because
> globassign is off, the equals expansion (on the empty string) is done,
> but the qualifiers are never applied to the result.
>
> If you "setopt shfileexpansion" so that equals applies after globbing
> instead of before, the assignment behaves more sensibly, but:
>
> The only use of $tf as far as I can see is to do lookups in the cache.
> The apparent intent is to canonicalize the cache name to avoid "tar -tf"
> of the same tar file more than once.  That optimization may not be worth
> the buggy attempt at expansion, and caching the result of =(command) may
> not be the best idea in the first place.

Presumably at some point the given filename has to be interpreted so
that it can give any completions at all, even if it's not cached? I
didn't look closely at the rest of the completer though.

> I'm not sure exactly what fix to suggest.

I wonder if there's anywhere in the completion system that depends on
EQUALS being set... But maybe we should just 2> /dev/null the
assignment since tilde expansion also prints errors. (_zattr and _zip
also have this issue, presumably there are other places as well).

-- 
Mikael Magnusson



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