Sanitize paths when pasting into a bash shell #2620

Closed
opened 2026-01-30 22:59:54 +00:00 by claunia · 2 comments
Owner

Originally created by @axfelix on GitHub (Jul 7, 2019).

Summary of the new feature/enhancement

Not sure if this is out of scope, but it would be nice if Windows Terminal could automatically sanitize paths (e.g. quoting spaces, inverting or escaping Windows-style slashes) when pasting to a non-cmd, non-Powershell environment. ConEmu's Far Manager does this and it makes mingw bash much more usable.

Proposed technical implementation details (optional)

Automatically make assumptions about the running shell and change pasted paths to match the interpreter flavour.

P.S.: Just noticed you already fixed the Windows Terminal gsyncing my entire desktop when it's focused, thanks! If you add this feature and a warning on quitting when you have an ssh connection open or another running program, I'll be really happy to switch to using Windows Terminal fulltime!

Originally created by @axfelix on GitHub (Jul 7, 2019). # Summary of the new feature/enhancement Not sure if this is out of scope, but it would be nice if Windows Terminal could automatically sanitize paths (e.g. quoting spaces, inverting or escaping Windows-style slashes) when pasting to a non-cmd, non-Powershell environment. ConEmu's Far Manager does this and it makes mingw bash much more usable. # Proposed technical implementation details (optional) Automatically make assumptions about the running shell and change pasted paths to match the interpreter flavour. P.S.: Just noticed you already fixed the Windows Terminal gsyncing my entire desktop when it's focused, thanks! If you add this feature and a warning on quitting when you have an ssh connection open or another running program, I'll be really happy to switch to using Windows Terminal fulltime!
claunia added the Issue-FeatureResolution-Duplicate labels 2026-01-30 22:59:54 +00:00
Author
Owner

@DHowett-MSFT commented on GitHub (Jul 7, 2019):

This'll also be related to #904 and #331; there's a bunch of pain in "detecting" on both sides of this problem.

The first is pain in detecting what is a path; for example, /Windows is a valid path to powershell on Windows, but it looks like an absolute WSL path. Blindly taking things off the clipboard and trying to access-check them is a recipe for a bad time, too, because that'll almost certainly bother more than one antivirus solution. Blindly taking things off the clipboard and trying to access-check them as WSL paths (for conversion back to Windows) is even more a recipe for a bad time, for the aforementioned^ and because WT cannot access check within your WSL distributions.

The second is detecting what the shell is on the other end of the terminal. For local shells it's possible, although easily fooled (wsl -> powershell.exe -> cmd.exe should be detected as cmd but the terminal only knows about wsl), and for remote shells it is impossible in the general case. 😄

@DHowett-MSFT commented on GitHub (Jul 7, 2019): This'll also be related to #904 and #331; there's a bunch of pain in "detecting" on both sides of this problem. The first is pain in detecting _what is a path_; for example, `/Windows` is a valid path to powershell on Windows, but it looks like an absolute WSL path. Blindly taking things off the clipboard and trying to access-check them is a recipe for a bad time, too, because that'll almost certainly bother more than one antivirus solution. Blindly taking things off the clipboard and trying to access-check them _as WSL paths_ (for conversion back to Windows) is even more a recipe for a bad time, for the aforementioned^ and because WT cannot access check within your WSL distributions. The second is detecting what the shell is on the other end of the terminal. For local shells it's possible, although easily fooled (wsl -> powershell.exe -> cmd.exe should be detected as cmd but the terminal only knows about wsl), and for remote shells it is impossible in the general case. :smile:
Author
Owner

@DHowett-MSFT commented on GitHub (Jul 8, 2019):

Also, this is #1772 😄

@DHowett-MSFT commented on GitHub (Jul 8, 2019): Also, this is #1772 :smile:
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#2620