zsh-workers
 help / color / mirror / code / Atom feed
From: Roman Perepelitsa <roman.perepelitsa@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Millian Poquet <millian.poquet@irit.fr>, zsh-workers@zsh.org
Subject: Re: [bug report] prompt can erase messages written on the terminal by background processes
Date: Thu, 8 Dec 2022 09:45:02 +0100	[thread overview]
Message-ID: <CAN=4vMqLGwFVpRSoGv0MUJtdE_8ECnC96kBv8Zhm-5vWqpwGyQ@mail.gmail.com> (raw)
In-Reply-To: <CAH+w=7aDn7SCv4Bao7ZQqtUaEv8EkvBXa15kM_nkF_GHLAcSFg@mail.gmail.com>

On Thu, Dec 8, 2022 at 4:46 AM Bart Schaefer <schaefer@brasslantern.com> wrote:
>
> On Wed, Dec 7, 2022 at 2:57 PM Roman Perepelitsa
> <roman.perepelitsa@gmail.com> wrote:
> >
> > On Wed, Dec 7, 2022 at 8:04 PM Millian Poquet <millian.poquet@irit.fr> 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.


  parent reply	other threads:[~2022-12-08  8:45 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-07 19:02 Millian Poquet
2022-12-07 22:55 ` Roman Perepelitsa
2022-12-08  3:46   ` Bart Schaefer
2022-12-08  8:21     ` Get cursor position (Was: [bug report] prompt can erase messages written on the terminal by background processes) Stephane Chazelas
2022-12-08  8:34       ` Roman Perepelitsa
2022-12-08 10:02         ` Stephane Chazelas
2022-12-08 10:10           ` Stephane Chazelas
2022-12-08 10:19           ` Mikael Magnusson
2022-12-09  2:19           ` Bart Schaefer
2022-12-09 12:46             ` Philippe Altherr
2022-12-10  4:30               ` Bart Schaefer
2022-12-10 14:55                 ` Private variables not private enough? (Was: Get cursor position (Was: [bug report] prompt can erase messages written on the terminal by background processes)) Philippe Altherr
2022-12-10 17:36                   ` Bart Schaefer
2022-12-10 20:38                     ` Bart Schaefer
2022-12-11 18:00               ` Get cursor position (Was: [bug report] prompt can erase messages written on the terminal by background processes) Stephane Chazelas
2022-12-09  1:39       ` Bart Schaefer
2022-12-08  8:45     ` Roman Perepelitsa [this message]
2022-12-08 15:03     ` [bug report] prompt can erase messages written on the terminal by background processes Oliver Kiddle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAN=4vMqLGwFVpRSoGv0MUJtdE_8ECnC96kBv8Zhm-5vWqpwGyQ@mail.gmail.com' \
    --to=roman.perepelitsa@gmail.com \
    --cc=millian.poquet@irit.fr \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).