Skip to content

Commit

Permalink
Don't escape quotes in args on Windows
Browse files Browse the repository at this point in the history
This was added recently to enable shell arguments to work on Windows
however I don't think we want to escape quotes but instead rely on the
consumer escaping the quotes since some windows commands require quotes
not to be escaped (eg. cmd.exe /c "dir "a b"").

Fixes microsoft#41
  • Loading branch information
Tyriar committed Feb 24, 2017
1 parent e48ebcb commit 220f91c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
4 changes: 0 additions & 4 deletions src/windowsPtyAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,6 @@ export function argvToCommandLine(argv: string[]): string {
const p = arg[i];
if (p === '\\') {
bsCount++;
} else if (p === '"') {
result += repeatText('\\', bsCount * 2 + 1);
result += '"';
bsCount = 0;
} else {
result += repeatText('\\', bsCount);
bsCount = 0;
Expand Down
18 changes: 9 additions & 9 deletions test/argvToCommandLine.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ describe("argvToCommandLine", function() {
it("doesn't escape multiple backslashes", function() {
check(['asdf\\\\qwer'], 'asdf\\\\qwer');
});
it("adds backslashes before quotes", function() {
check(['"asdf"qwer"'], '\\"asdf\\"qwer\\"');
it("should not add backslashes before quotes", function() {
check(['"asdf"qwer"'], '"asdf"qwer"');
});
it("escapes backslashes before quotes", function() {
check(['asdf\\"qwer'], 'asdf\\\\\\"qwer');
it("escapes backslashes, not quotes", function() {
check(['asdf\\"qwer'], 'asdf\\"qwer');
});
});

Expand All @@ -42,11 +42,11 @@ describe("argvToCommandLine", function() {
it("doesn't escape multiple backslashes", function() {
check(['asdf \\\\qwer'], '"asdf \\\\qwer"');
});
it("adds backslashes before quotes", function() {
check(['"asdf "qwer"'], '"\\"asdf \\"qwer\\""');
it("doesn't escape quotes", function() {
check(['"asdf "qwer"'], '""asdf "qwer""');
});
it("escapes backslashes before quotes", function() {
check(['asdf \\"qwer'], '"asdf \\\\\\"qwer"');
it("escapes backslashes, not quotes", function() {
check(['asdf \\"qwer'], '"asdf \\"qwer"');
});
it("escapes multiple backslashes at the end", function() {
check(['asdf qwer\\\\'], '"asdf qwer\\\\\\\\"');
Expand All @@ -55,7 +55,7 @@ describe("argvToCommandLine", function() {

describe("Multiple arguments", function() {
it("joins arguments with spaces", function() {
check(['asdf', 'qwer zxcv', '', '"'], 'asdf "qwer zxcv" "" \\"');
check(['asdf', 'qwer zxcv', '', '"'], 'asdf "qwer zxcv" "" "');
});
});
});

0 comments on commit 220f91c

Please sign in to comment.