bug-readline
[Top][All Lists]
Advanced

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

Re: Bracketed paste mode prints newline on EOF


From: Chet Ramey
Subject: Re: Bracketed paste mode prints newline on EOF
Date: Tue, 4 Jan 2022 15:00:03 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.4.1

On 1/4/22 6:10 AM, Leah Neukirchen wrote:
> Hi,
> 
> I first thought I found a bug in rlwrap[1], but we traced it down to
> readline.  When "enable-bracketed-paste" is on (default as of 8.1),
> an empty line is printed when readline() gets EOF.

Yes. More precisely, readline outputs "\n" after outputting the escape
sequence to turn off bracketed paste mode.

That escape sequence ends with "\r" to work around an issue with the Linux
terminal driver that causes it to become confused about the physical cursor
location. That leaves the cursor in column 0.

(The discussion that prompted that change is interesting:
https://lists.gnu.org/archive/html/bug-bash/2018-01/msg00097.html .)

Once the cursor is in column 0, and the EOF (presumably) causes the process
to exit, the cursor is still on the same line as when readline got EOF. To
avoid overwriting any of the text on that line, readline outputs a newline,
which moves the cursor to the next physical line.

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=903936 discusses that
phenomenon.

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



reply via email to

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