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

Re: Unexpected foo==bar errors



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.

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.

torch% bar==echo
torch% print $bar
/bin/echo
torch% print foo==echo
foo==echo
torch% setopt magicequalsubst
torch% print foo==echo       
foo=/bin/echo
torch% setopt no_equals
torch% print foo==echo    
foo==echo
torch% bar==echo
torch% print $bar
=echo
torch% 

} _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.

I'm not sure exactly what fix to suggest.



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