Copy of a single wrapped line from bash introduces new-lines #18512

Closed
opened 2026-01-31 06:16:22 +00:00 by claunia · 10 comments
Owner

Originally created by @vadimkantorov on GitHub (Sep 19, 2022).

Windows Terminal version

1.14.2282.0

Windows build number

10.0.22000.978

Other Software

No response

Steps to reproduce

I have launched a long command in WSLv1 bash in Terminal, it looks like:

vadimkantorov@dell_de_vadim:/mnt/c/Users/vadim/$ python ..... my long arguments
long arguments wrapped by terminal window size but still a single line

When I copy these two lines (e.g. for pasting later in another terminal for launching a similar command in parallel), Terminal introduces a newline which was not there originally. This prevents from a proper paste and (probably another issue) - also executes the incomplete command immediately after the paste. It's possible that I entered this command by pressing Up on keyboard which brought this command from bash history.

This must have been reported before, but I could not find an earlier issue just about this. If it indeed is a duplicate, please feel free to close this.

Expected Behavior

No response

Actual Behavior

No newline is introduced and command is not executed immediately after the paste in another tab

Originally created by @vadimkantorov on GitHub (Sep 19, 2022). ### Windows Terminal version 1.14.2282.0 ### Windows build number 10.0.22000.978 ### Other Software _No response_ ### Steps to reproduce I have launched a long command in WSLv1 bash in Terminal, it looks like: ```bash vadimkantorov@dell_de_vadim:/mnt/c/Users/vadim/$ python ..... my long arguments long arguments wrapped by terminal window size but still a single line ``` When I copy these two lines (e.g. for pasting later in another terminal for launching a similar command in parallel), Terminal introduces a newline which was not there originally. This prevents from a proper paste and (probably another issue) - also executes the incomplete command immediately after the paste. It's possible that I entered this command by pressing Up on keyboard which brought this command from bash history. This must have been reported before, but I could not find an earlier issue just about this. If it indeed is a duplicate, please feel free to close this. ### Expected Behavior _No response_ ### Actual Behavior No newline is introduced and command is not executed immediately after the paste in another tab
claunia added the Issue-BugResolution-Duplicate labels 2026-01-31 06:16:22 +00:00
Author
Owner

@DHowett commented on GitHub (Sep 19, 2022):

This is a bit nuanced.

bash (more accurately, probably readline) implements its own hard wrapping. As a result, we can't totally tell that a line was intended to be a continuation instead of a physical line break.

When I type this:

image

Bash sends this:

reach the edge ABCDEFGHIJKL:M \nNOP
                             ^^^

That space and newline were produced by them. I'm at a loss as to exactly why they do this. ☹️

@DHowett commented on GitHub (Sep 19, 2022): This is a bit nuanced. bash (more accurately, probably readline) implements its own hard wrapping. As a result, we can't totally tell that a line was intended to be a continuation instead of a physical line break. When I type this: <img width="850" alt="image" src="https://user-images.githubusercontent.com/189190/191073975-c0b3d492-dc54-4644-ac94-719358218a13.png"> Bash sends this: ``` reach the edge ABCDEFGHIJKL:M \nNOP ^^^ ``` That space and newline were produced by them. I'm at a loss as to exactly _why_ they do this. ☹️
Author
Owner

@vadimkantorov commented on GitHub (Sep 19, 2022):

probably the command is actually executed because of this newline too

@vadimkantorov commented on GitHub (Sep 19, 2022): probably the command is actually executed because of this newline too
Author
Owner

@vadimkantorov commented on GitHub (Sep 19, 2022):

maybe could be hacked around by a context menu command "Paste without newlines", but it's not very satisfactory

@vadimkantorov commented on GitHub (Sep 19, 2022): maybe could be hacked around by a context menu command "Paste without newlines", but it's not very satisfactory
Author
Owner

@DHowett commented on GitHub (Sep 19, 2022):

Holding down Shift while you copy will force the entire selection to wrap onto a single line. It's not ideal because you won't necessarily know when to use it versus not use it, but it might be a good tactical solution for this specific issue. Sorry :/

@DHowett commented on GitHub (Sep 19, 2022): Holding down <kbd>Shift</kbd> while you copy will force the entire selection to wrap onto a single line. It's not ideal because you won't necessarily know when to use it versus not use it, but it might be a good tactical solution for this specific issue. Sorry :/
Author
Owner

@vadimkantorov commented on GitHub (Sep 19, 2022):

Until now, I've been relying on auto-copy on mouse selection. I wonder, if Terminal can at least provide some visual hints on copy or on paste if the text includes new-lines to educate about this option. Btw Ctrl+Shift+C is default on Gnome Terminal, will this shortcut in WT also just apply these newline removal? or only if Shift is used during mouse-selection?

@vadimkantorov commented on GitHub (Sep 19, 2022): Until now, I've been relying on auto-copy on mouse selection. I wonder, if Terminal can at least provide some visual hints on copy or on paste if the text includes new-lines to educate about this option. Btw Ctrl+Shift+C is default on Gnome Terminal, will this shortcut in WT also just apply these newline removal? or only if Shift is used during mouse-selection?
Author
Owner

@vadimkantorov commented on GitHub (Sep 19, 2022):

That space and newline were produced by them. I'm at a loss as to exactly why they do this. ☹️

Yea, I wonder if there's somewhere a mailing list or bash/readline authors that could address this...

Does Mac's Terminals handle this somehow?

@vadimkantorov commented on GitHub (Sep 19, 2022): > That space and newline were produced by them. I'm at a loss as to exactly _why_ they do this. ☹️ Yea, I wonder if there's somewhere a mailing list or bash/readline authors that could address this... Does Mac's Terminals handle this somehow?
Author
Owner

@vadimkantorov commented on GitHub (Sep 19, 2022):

Also, I don't know why but for me this problem doesn't happen every time, only occasionally. So there may be some other aspects

@vadimkantorov commented on GitHub (Sep 19, 2022): Also, I don't know why but for me this problem doesn't happen every time, only occasionally. So there may be some other aspects
Author
Owner

@zadjii-msft commented on GitHub (Nov 8, 2022):

I think I'm gonna call this a /dupe of #6901. We should probably go through and de-dupe the rest of those too.

@zadjii-msft commented on GitHub (Nov 8, 2022): I think I'm gonna call this a /dupe of #6901. We should probably go through and de-dupe the rest of those too.
Author
Owner

@ghost commented on GitHub (Nov 8, 2022):

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@ghost commented on GitHub (Nov 8, 2022): Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#18512