←back to thread

217 points tanelpoder | 3 comments | | HN request time: 0.7s | source
Show context
marcosdumay ◴[] No.26494383[source]
I guess the most important message isn't even "don't paste things into the terminal". It's "don't use a terminal that pastes things automatically, or by some action you will do by mistake".

Or, more specifically, don't ever use the default behavior of putty in a laptop with a trackpad and a gesture enabled for left click. If you use putty, set copy and paste to something less random.

replies(2): >>26494657 #>>26494994 #
1. scaladev ◴[] No.26494994[source]
When pasting something to the terminal (especially if it's longer than one line or was copied from an untrusted source), I like this approach:

1. open your terminal emulator;

2. press Ctrl-X + Ctrl-E in a shell prompt;

3. it opens your $EDITOR, paste the command there, check it for anything unusual, then save and exit;

4. the shell runs whatever was in that script you saved.

replies(1): >>26495322 #
2. kzrdude ◴[] No.26495322[source]
Nice, thanks, learned something :)

Tip for Vi/Vim users: to exit without having the command run, exit the editor with failure; the command for that is is :cq in Vim. (Also works fine in git to cancel commits etc.)

replies(1): >>26495682 #
3. marcosdumay ◴[] No.26495682[source]
Adding for emacs users, the kill-emacs command does the same. I don't think it has a shortcut by default, so it's M-x kill-emacs.