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

Re: [PATCH] Completion batch #2: Misc. trivial fixes



On 3 Jan 2018, at 18:03, dana <dana@xxxxxxx> wrote:
>The way i had handled this in the _busybox function is:
>
>  _cmd_variant[${words[1]}]=busybox _normal
>
>That way you can temporarily override what _pick_variant thinks the actual
>variant is. This seems to work quite well, but i did feel some guilt about it,
>since as you mention it's circumventing the interface.

I was playing with this some more to see if i could come up with a better way
and actually discovered a problem with the method i described: it is *not* a
temporary override. Apparently pre-command re-assignment of array members
doesn't work the same way it does with scalars — zsh doesn't put the value back
the way it was when it's done executing the command. I assume the same code is
involved here as with the issue i brought up in workers/42097:

http://www.zsh.org/mla/workers/2017/msg01761.html

Anyway, i suppose i could re-assign or unset it afterwards (according to
whatever the previous state was), but... it sure is starting to feel fragile.

Exporting something to the environment is the natural thing that comes to mind
when i need to communicate with a function that i'm two or three calls removed
from. I guess it could learn about a new scalar? _cmd_variant_override or
something? I don't know. There are lots of ways i could change this to work for
my use case, i just don't want to leave a mess. :/

dana



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