Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [bug report] prompt can erase messages written on the terminal by background processes
- X-seq: zsh-workers 51133
- From: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Cc: Millian Poquet <millian.poquet@xxxxxxx>, zsh-workers@xxxxxxx
- Subject: Re: [bug report] prompt can erase messages written on the terminal by background processes
- Date: Thu, 8 Dec 2022 09:45:02 +0100
- Archived-at: <https://zsh.org/workers/51133>
- In-reply-to: <CAH+w=7aDn7SCv4Bao7ZQqtUaEv8EkvBXa15kM_nkF_GHLAcSFg@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <9e3026aa-39a1-dd50-4d29-a64724d4eaaf@irit.fr> <CAN=4vMq2kc1cSV_0N-c6o32C3UR3hVSjE3mF+kV4pjcy7YR9=g@mail.gmail.com> <CAH+w=7aDn7SCv4Bao7ZQqtUaEv8EkvBXa15kM_nkF_GHLAcSFg@mail.gmail.com>
On Thu, Dec 8, 2022 at 4:46 AM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> On Wed, Dec 7, 2022 at 2:57 PM Roman Perepelitsa
> <roman.perepelitsa@xxxxxxxxx> wrote:
> >
> > On Wed, Dec 7, 2022 at 8:04 PM Millian Poquet <millian.poquet@xxxxxxx> wrote:
> > >
> > > prompt can erase messages written on the terminal by background processes
> >
> > There is no way around it. Zle assumes that nobody else prints to the terminal.
>
> Perhaps try this.
>
> get_cursor_pos() {
> print -n $'\e[6n'
> IFS=$'\e[;' read -s -d R -A ${1:-reply}
> shift 3 ${1:-reply}
> }
> precmd() {
> local rowcol
> get_cursor_pos rowcol
> if (( $rowcol[1] > 1 ))
> then print
> fi
> }
Here's the simplified version of Millian's test:
% setopt prompt_subst; PS1='%# $(sleep 2)'; ( sleep 1; print -n hello ) &!
This prints "hello" and then erases it. The precmd hook runs before
prompt expansion, so it has no effect.
Even if this somehow worked for this test case, it would merely mask
the problem. Zle has to assume that nobody else writes to the TTY.
It's user error to violate this assumption.
Roman.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author