Terminal should prompt for confirmation before pasting text containing newlines

Bug #1791337 reported by teo1978 on 2018-09-07
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gnome-terminal (Ubuntu)
Undecided
Unassigned

Bug Description

Steps to reproduce:
- copy some texts that includes newline characters
- paste it (usually accidentally) in a terminal

Expected behavior:
Before pasting something that will be executed (because newline characters will be processed as if hitting the Enter key), the terminal should prompt for confirmation.
OR at least, what you paste should be only displayed and not actually processed until you press the Enter key.

THIS SHOULD BE F***ING OBVIOUS, I can't believe I have to report this.

Observed behavior:
blindly pastes everything and executes each line as a command.

THIS IS F***ING DANGEROUS.

It's too easy to forget to copy what you actually meant to copy, or forget you copied something else afterwards, and accidentally paste a random block of text of several lines which usually isn't even shell commands, but some of them can actually happen to be valid commands that actually do stuff.

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: gnome-terminal 3.18.3-1ubuntu1
ProcVersionSignature: Ubuntu 4.4.0-134.160-generic 4.4.140
Uname: Linux 4.4.0-134-generic x86_64
NonfreeKernelModules: nvidia_uvm nvidia
ApportVersion: 2.20.1-0ubuntu2.18
Architecture: amd64
CurrentDesktop: Unity
Date: Fri Sep 7 18:32:28 2018
InstallationDate: Installed on 2013-10-11 (1791 days ago)
InstallationMedia: Ubuntu 13.04 "Raring Ringtail" - Release amd64 (20130424)
SourcePackage: gnome-terminal
UpgradeStatus: No upgrade log present (probably fresh install)

teo1978 (teo8976) wrote :
teo1978 (teo8976) wrote :

Obviously this should be fixed upstream, but until then, a decent distribution would patch it to fix such an idiotic behaviour.

Egmont Koblinger (egmont-gmail) wrote :

I'm not affiliated with Ubuntu, so I probably shouldn't be the one warning you, but your style is unacceptable, no matter how serious issue you report.

gnome-terminal could warn you before pasting a newline. It could offer to disable that warning, in which case most users would do so, falling back to the problem you reported. Or it could not offer such possibility, making intentional multi-line pastes annoying as hell.

I believe the proper solution is to enable bracketed paste mode in your shell (which requires a newer Ubuntu, shipping bash-4.4). Please reassign (or report a new bug) against Ubuntu's bash or readline package to enable this feature by default.

teo1978 (teo8976) wrote :

> gnome-terminal could warn you before pasting a newline. It could offer
> to disable that warning,

Yep, it should do both things (I forgot to mention the second one), or, as I said, just require a single Enter keystroke (and still, obviously have a setting to disable that). I don't think having to hit Enter when you paste several lines, just like you usually do when you paste a single line (usually not including the final newline) would be a great annoyance for those who often paste whole sequences of commands, but if it was for someone, there would always be the setting to disable it.

> I believe the proper solution is to enable bracketed paste mode

Does that address the case where I actually do want to paste a sequence of commands and run them?

Egmont Koblinger (egmont-gmail) wrote :

> I don't think having to hit Enter when you paste several lines [...] would be a great annoyance

You have the shell as use case in your mind. Other use cases include e.g. pasting to a text editor. Having to hit Enter there would be quite an annoyance.

> but if it was for someone, there would always be the setting to disable it.

And that's the problematic part. I'd like to have it disabled when running the text editor, but have some confirmation when pasting to the shell.

> Does that address the case where I actually do want to paste a sequence of commands and run them?

Yes. You just hit Enter.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers