zsh-workers
 help / color / mirror / code / Atom feed
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: Roman Perepelitsa <roman.perepelitsa@gmail.com>
Cc: Daniel Shahaf <d.s@daniel.shahaf.name>,
	Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: A serious bug in execution – where to debug?
Date: Wed, 31 Jul 2019 15:10:39 +0200	[thread overview]
Message-ID: <CAKc7PVCeNC=OE87QECJM=YsnRHbUn4prrYFFFnXqpeoa3gjVbQ@mail.gmail.com> (raw)
In-Reply-To: <CAN=4vMpHzHVyrs94QYPwjf+Bu0h_PJABsG14SxgQGEq1uHqU4g@mail.gmail.com>

On Wed, 31 Jul 2019 at 14:40, Roman Perepelitsa
<roman.perepelitsa@gmail.com> wrote:
> ...
> How is this possible?
>
>   foo.zsh:  alias grep='grep --color=auto'
>   bar.zsh:  function bar() { grep hello <<<hello }
>   baz.zsh  alias grep='grep --color=auto'

Thanks for bringing this up into the light. It's a good example of the
problems with unloading. It also hints an extension to zplugin – to
test whether the alias' value is the one expected to be and hold the
unsetting/restoration of the alias if it isn't. So, if baz would set
alias grep='grep -B1 --color=auto', then things would work as
expected. And that's how it is with the unloading – it *often* works,
sometimes doesn't. But still, it's an useful tool that can be often
used.

> You can get the same problems when reverting changes to any resource
> with a shared name: aliases, traps, options, widgets. All code that
> ran after the plugin you are attempting could've been affected by the
> value you are reverting.

Ok, but the unloading can still be useful. For example, besides the
MYPROMPT=1..8 use case, I'm also using it often when developing a
plugin, instead of the shell restart. It allows for a quick
unfunction/redeclaration of autoload functions, for example.

> Removing widgets is very likely to break your prompt due to the way
> widgets are commonly hooked. When a decent plugin wants to hook a zle
> widget, it will copy the previous widget and install its own.
> ...
> if *this* widget gets wrapped too, and you remove it, the chain of
> hooks is broken.

This particular case will be solved if the plugin will use
add-zle-hook-widget instead of wrapping (support for this isn't yet in
zplugin, but it'll be there soon).

> > I think that it's actually possible to predict to a large extent by
> > looking at the list of unload-actions.
>
> You can predict which aliases will be unset and which widgets removed
> but you cannot predict how it will affect shell. Things can break a
> little or a lot. Things may look OK but do damage behind the scenes.

To sum up, your opinion is a mathematical-like proof that:

* You cannot implement an unloading that just works as expected.

While my opinion is a practical-view -like point that:

* You can often get good results with unloading, just try & test it
first with the plugin that you need to unload.

-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org

  reply	other threads:[~2019-07-31 13:17 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-30 17:00 Sebastian Gniazdowski
2019-07-30 17:05 ` Sebastian Gniazdowski
2019-07-30 17:41 ` Roman Perepelitsa
2019-07-30 17:55   ` Sebastian Gniazdowski
2019-07-30 18:12     ` Roman Perepelitsa
2019-07-30 18:16       ` Sebastian Gniazdowski
2019-07-30 18:22         ` Roman Perepelitsa
2019-07-30 18:53           ` Sebastian Gniazdowski
2019-07-30 19:23             ` Roman Perepelitsa
2019-07-30 19:34               ` Sebastian Gniazdowski
2019-07-30 19:41                 ` Roman Perepelitsa
2019-07-30 19:59                   ` Sebastian Gniazdowski
2019-07-30 20:08                     ` Roman Perepelitsa
2019-07-30 20:38                       ` Sebastian Gniazdowski
2019-07-30 18:27 ` Bart Schaefer
2019-07-30 18:46   ` Sebastian Gniazdowski
2019-07-30 21:02     ` Roman Perepelitsa
2019-07-30 21:38       ` Sebastian Gniazdowski
2019-07-30 21:45         ` Roman Perepelitsa
2019-07-30 21:54           ` Sebastian Gniazdowski
2019-07-30 22:11             ` Roman Perepelitsa
2019-07-30 22:18           ` Daniel Shahaf
2019-07-30 22:32             ` Roman Perepelitsa
2019-07-31  1:30               ` Sebastian Gniazdowski
2019-07-31  7:23                 ` Roman Perepelitsa
2019-07-31 11:41                   ` Sebastian Gniazdowski
2019-07-31 12:40                     ` Roman Perepelitsa
2019-07-31 13:10                       ` Sebastian Gniazdowski [this message]
2019-07-31 13:34                         ` Roman Perepelitsa
2019-07-31 13:40                           ` Sebastian Gniazdowski
2019-07-31 14:11                             ` Roman Perepelitsa
2019-07-31 17:56                               ` Sebastian Gniazdowski
2019-07-31  1:42               ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKc7PVCeNC=OE87QECJM=YsnRHbUn4prrYFFFnXqpeoa3gjVbQ@mail.gmail.com' \
    --to=sgniazdowski@gmail.com \
    --cc=d.s@daniel.shahaf.name \
    --cc=roman.perepelitsa@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).