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

Re: [PATCH] Add execute-command() widget function (was Re: [RFC][PATCH] Add change-directory() widget function)



On Mon, Apr 26, 2021 at 11:09 AM Marlon Richert
<marlon.richert@xxxxxxxxx> wrote:
>
> On Sun, Apr 25, 2021 at 12:58 AM Bart Schaefer
> <schaefer@xxxxxxxxxxxxxxxx> wrote:
> > execute-command () {
> >   case $CONTEXT in
> >     (cont|start) print -rz -- "$PREBUFFER$BUFFER"
> >       print -rS -- "${${(q-)@}}"
> >       eval "${(q-)@}" ;;
> >     (*) return 75 ;;
> >   esac
> >   zle .send-break
> > }
>
> I tried it and it's otherwise good, but that last line causes %? == 1
> and %(? == true. Can that be fixed somehow?

I would think that occurs with "zle .push-line-or-edit" also?

Anyway, no, there's no way to abort the current ZLE without $?
becoming nonzero.  A lot of effort was put into preserving the value
of $? across everything that comes in between the previous command
ending (even if it ended by interrupting ZLE) and the next prompt
being printed.

I believe you'll see similar things with e.g. edit-command-line from
the distribution, if it happens to take the branch that calls
send-break.




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