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

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



On Tue, 30 Jul 2019 at 23:45, Roman Perepelitsa
<roman.perepelitsa@xxxxxxxxx> wrote:
>
> 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

I avoided localoptions for performance – it consumes some time, as it
(probably, but the performance effect is confirmed) allocates a new
table of options and fills it with defaults. So I've decided to write
an option-transparent code. But turns out that this might be hard in
case of such options as errreturn. I'll think about whether to replace
inline conditions with if-then or to do emulate -L.

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



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