Bash, via GNU Readline, has an option that sidesteps this issue:
enable-bracketed-paste (On)
When set to On, readline will configure the terminal in a way
that will enable it to insert each paste into the editing buf‐
fer as a single string of characters, instead of treating each
character as if it had been read from the keyboard. This can
prevent pasted characters from being interpreted as editing
commands.
Effectively it means that even if you paste garbage into the terminal you still have to hit enter before the command is interpreted. replies(4):