Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape single quotes for WSL #18007

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/cascadia/TerminalControl/TermControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3287,7 +3287,26 @@ namespace winrt::Microsoft::Terminal::Control::implementation
{
allPathsString.push_back(quotesChar);
}
allPathsString.append(fullPath);
if (isWSL)
{
// Fix quoted path for WSL
// Single quote is allowed on the Win32 subsystem and must be processed
// when we are quoting the path with single quotes (on WSL).
// Note that we assume that all paths are quoted for WSL.
std::wstring_view fullPathView{ fullPath };
size_t pos;
while ((pos = fullPathView.find(L'\'')) != std::wstring_view::npos)
{
allPathsString.append(fullPathView.begin(), fullPathView.begin() + pos);
allPathsString.append(L"'\\''");
fullPathView.remove_prefix(pos + 1);
}
allPathsString.append(fullPathView);
}
else
{
allPathsString.append(fullPath);
}
if (quotesNeeded)
{
allPathsString.push_back(quotesChar);
Expand Down
Loading