bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: print/echo lost from COMMAND_PROMPT Function


From: Chet Ramey
Subject: Re: print/echo lost from COMMAND_PROMPT Function
Date: Tue, 4 Feb 2020 10:07:50 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.4.2

On 2/3/20 3:26 PM, Manish Patel wrote:

> Bash Version: 4.4
> Patch Level: 20
> Release Status: release
> 
> Description:
>         Print/echo is lost when generated from a function in
> COMMAND_PROMPT and placed in background in subshell.
> 
> I have embedded some git information in my command prompt.
> However, due to large git data, it takes some time to calculate it all.
> So I have placed
> the git processing in the background function, which I call from
> COMMAND_PROMPT.

Readline assumes two things: it starts with the cursor in column 0, and
it is the only thing writing to the screen during redisplay, so it always
knows where the cursor is and can make redisplay decisions accordingly.
Your writing to the screen from a background process violates one or both
of these, so all bets are off. It may be the case that readline decides to
redisplay by moving to column 0, redrawing the prompt, moving the cursor,
and redrawing the changed portions of the line,in which case whatever your
process writes at the beginning of the line gets overwritten. It may be the
case that writing to the screen moves the cursor forward so readline
doesn't move the cursor to the right place or wrap correctly.

There are no guarantees that anything a background process writes to the
screen will be preserved, or that writing to the screen and moving the
physical cursor will not interfere with readline's redisplay.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden    http://tiswww.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]