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

Re: PATCH: funcstack[-1] (formerly Suppress tracing of "set +x")



On Fri, 05 Feb 2016 09:20:38 -0800
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> My concern is that $_tags_level is initialized to 0 in _main_complete
> and then compared to $#funcstack later.  If $#funcstack is now always no
> less than 1, that will be wrong.

Hmmm... I'm not convinced this *particular* example is a killer.  As I
said, the completion system doesn't care what functions are on top of
it. So 0 is just "a safe value that can't be as much as what we're
going to get to to when we start running completion functions".  So
actually it's fine as it is.  (Any completion function will always see
at least 1 with the current code because of the way the system works
and we never guarantee at what level you're going to reach the
nitty gritty.)

> Of course we can fix _main_complete to initialize to 1, but this does
> imply that comparisons to $#funcstack are not an unknown programming
> technique.

Indeed, that was basically my question, although actually it should have
been the slightly more subtle "are *absolute* comparisons to
${#funcstack}, as opposed to differences, used", which is still
plausible.

pws



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