bug-readline
[Top][All Lists]
Advanced

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

Re: Bracketed paste causes readline() to return multiple lines


From: Martin Buck
Subject: Re: Bracketed paste causes readline() to return multiple lines
Date: Wed, 3 Jan 2024 01:21:27 +0100
User-agent: Mutt/1.10.1 (2018-07-13)

On Tue, Jan 02, 2024 at 04:43:40PM -0500, Chet Ramey wrote:
> I see how this can be confusing. The whole idea behind bracketed paste is
> that everything in the pasted text is inserted into the readline line,
> without any of the characters causing execution of any readline function
> that might be bound to them. Think of it as if you had executed the
> readline `quoted-insert' command before every character in the pasted text.

Thanks for your quick explanation! May I suggest a big fat warning in the
docs next to the "single line, no newline" description of readline(), making
library users more aware of the fact that they can't rely on always getting
just a single line?

> It's always been possible to do this, even before bracketed paste, by using
> quoted-insert.

Sure, but before bracketed-paste-defaults-to-on you had to try really hard
to make an appplication that expects a single line to misbehave whereas now
you can trigger this easily and involuntarily with each paste operation. And
to the average user, it's probably not obvious at all what's going on and
how to avoid it.

> Bracketed paste is all or nothing: either it's on and everything that
> gets pasted is inserted into the line buffer, or it's off and every pasted
> character is treated as if it had been typed at the keyboard and causes
> execution of any readline function bound to it.

I thought the main idea behind bracketed paste is the possibility to review
what you're pasting before it takes effect as Karl described in the other
email in this thread. I can see use in having this on by default, but I'm
not so sure about the "don't execute bound functions" part of it. So the
patch that Karl describes sounds very useful to me. But then, I don't have
the slightest idea about how bracketed paste is imlpemented internally and
I understand that what I'm asking for might actually be quite tricky to
implement.

So for the time being, I'll probably teach calc
https://github.com/lcn2/calc/ (that's the application where a user noticed
that multi-line-paste no longer works as expected) to handle multi-line
return values from readline() properly to make it indepedent of however
bracketed paste might behave in the future.

BTW, thanks a lot for maintaining readline and bash! I wrote an article
about the new features in bash 2.0 for the German Linux Magazin in 1997 and
it's cool to see that it's still maintained by the same hard-working hands
:-)

Martin



reply via email to

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