Skip to content

Commit

Permalink
Quotation fix for #22
Browse files Browse the repository at this point in the history
  If wslbridge and backend are installed in the folder containing spaces,
  bash exits immediately with error

  wslbridge error: failed to start backend process
  note: backend error output: /bin/bash: /mnt/c/Program: No such file or directory
  • Loading branch information
Maximus5 authored and rprichard committed May 5, 2018
1 parent 51e9f9f commit 47b41be
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions frontend/wslbridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -713,14 +713,15 @@ static void appendBashArg(std::wstring &out, const std::wstring &arg) {
inQuote = newInQuote;
}
};
enterQuote(true);
for (auto ch : arg) {
if (ch == L'\'') {
enterQuote(false);
out.append(L"\\'");
enterQuote(true);
} else if (isCharSafe(ch)) {
out.push_back(ch);
} else {
enterQuote(true);
out.push_back(ch);
}
}
Expand Down Expand Up @@ -1129,11 +1130,11 @@ int main(int argc, char *argv[]) {

// Prepare the backend command line.
std::wstring bashCmdLine;
bashCmdLine.append(L"$(if [ \"$(command -v wslpath)\" ]; then wslpath");
bashCmdLine.append(L"\"$(if [ \"$(command -v wslpath)\" ]; then wslpath");
appendBashArg(bashCmdLine, backendPathWin);
bashCmdLine.append(L" || echo false; else echo");
appendBashArg(bashCmdLine, backendPathWsl);
bashCmdLine.append(L"; fi)");
bashCmdLine.append(L"; fi)\"");

if (debugFork) {
appendBashArg(bashCmdLine, L"--debug-fork");
Expand Down

0 comments on commit 47b41be

Please sign in to comment.