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

Re: Aborted command saved in history

On Jan 28,  7:56am, Mikael Magnusson wrote:
} Is it expected that the line is saved [on keyboard interrupt]
} at all though? If you do a get-line and then ctrl-c twice, it is not
} saved, so a possible argument that "you accepted the first part of the
} line when you pressed enter" seems a bit weak to me.

The decision is made based on whether the parser returned anything.  In
the PS2 prompt case, the parser was invoked upon the first accept-line,
whereas in the get-line case the parser was never invoked at all.

This is how it has always worked (and I believe also how history is
handled in csh, whence this is all derived) but I'm not averse to
someone investigating how to change it.  I just don't plan to do so

Incidentally ZLE_LINE_ABORTED only gets the part that hasn't already
been through the parser, e.g. from the PS2 prompt in the first example.
If we remove the "prebuffer" from the history, we should put it into
ZLE_LINE_ABORTED instead.  Although I suspect that might confuse some

} Usually when I get a continuation prompt it's because I mistyped
} something, so I press ctrl-c to get out of the continuation and then
} retrieve it with uparrow and try again.

Incidentally this is exactly what push-line-or-edit is for, and is
very nearly what it does.

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