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

Re: A serious bug in execution – where to debug?

On Tue, Jul 30, 2019 at 11:38 PM Sebastian Gniazdowski
<sgniazdowski@xxxxxxxxx> wrote:
> On Tue, 30 Jul 2019 at 23:02, Roman Perepelitsa
> <roman.perepelitsa@xxxxxxxxx> wrote:
> >> On Tue, 30 Jul 2019 at 20:28, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> >> > If you change the [[ ... ]] && ... to an if/then, does the behavior change?
> >> > If you add a "return" or "return $?" at the end of the function, does it change?
> >>
> >> a) yes, the problem cancels with if-then
> >> b) no, adding one of the return's doesn't change the behavior
> >
> > I think Bart solved it. Do you have `emulate -L zsh` in your `zle` function?
> No, but adding it helps. Any emulation (sh, ksh) does. Aah, so this is
> the errreturn option set within your plugin! and the if-then was
> setting the return code to 0. A very interesting situation, having
> your code called in foreign context, to know what options to defend
> from.

You should call `emulate -L zsh` from every functions that can be
called by any code other than yours. It's almost impossible to write
code that works the same way with all combinations of options. In my
public code I also unset aliases. These defensive measures reduce the
number of bug reports by *a lot*. People really seem to like creating
global aliases with single-letter names. I'll probably start calling
`disable -f` for all builtins I use.


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