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

Re: Bad effect of error in zle-line-pre-redraw



On Sat, Nov 12, 2016 at 6:03 PM, Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
> If you happen to introduce an error into zle-line-pre-redraw,
> your shell is pretty badly wrecked -- ZLE resets itself after every
> character typed.  Stupid minimal example:
>
> torch% zle-line-pre-redraw() { : ${bad_subscript[missing-bracket} }
> torch% zle -N zle-line-pre-redraw
> torch% e
> zle-line-pre-redraw: invalid subscript
> torch% e
> torch% c
> zle-line-pre-redraw: invalid subscript
> torch% c
> torch% h
> zle-line-pre-redraw: invalid subscript
> torch% h
> torch% o
> zle-line-pre-redraw: invalid subscript
> torch% o
> torch%
>
> Why the missing bracket isn't a syntax error at parse time rather
> than an evaluation error at run time is left as an exercise; e.g. ksh
> complains when defining the function.
>
> Other hook functions (zle-history-line-set, etc.) don't have this side-
> effect.

% foo() { : ${bad_subscript[missing-bracket} }
% zle -N self-insert foo
{5514|18:54:05|~}%
foo: invalid subscript
{5514|18:54:05|~}%
{5514|18:54:05|~}%
foo: invalid subscript
{5514|18:54:05|~}%
{5514|18:54:05|~}%

There are many many more ways to break a shell session, surely.

-- 
Mikael Magnusson



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