Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • 1
    The thing you see at the end is definitely not a "space", it's a "Enter" (aka "newline" or \n). That's the symbol I see when I do <kbd>Shift+Enter</kbd> with libreoffice. A space at the end of a command will never make a bash command to execute. Also, I'm not sure I really understood your problem : do you only want to prevent bash from executing any text you pasted ? Or do you want something more ? Commented Apr 8, 2021 at 19:56
  • 1
    @ewen-goisot - answered under you answer. Commented Apr 9, 2021 at 7:29
  • FYI, bash automatically appends a newline to a "here string".  See bash(1): "The result is supplied as a single string, with a newline appended, to the command on its standard input".  Try printf '%s' 'MY_COMMAND' | xsel -ib instead. Commented Apr 11, 2021 at 22:07