Skip to content

Commit

Permalink
Fixed double quotes on Power Shell.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhop committed Sep 5, 2024
1 parent 208b5c1 commit f189e28
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/shell/windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ const mapControls = {
'\x00': '`0',
'\x07': '`a',
'\x1B': '`e',
'\x0B': '`v'
'\x0B': '`v',
'"': '`\\"'
};

const escapePowerShell = (_, controls, nonAlphas, theRest) => {
Expand All @@ -41,7 +42,7 @@ export const shellEscape = (s, options, isFirst) => {
if (!/[\"\\]/.test(s)) return `"${s}"`;

let quoteHit = true;
const result = (
const result =
'"' +
[...s]
.map(c => {
Expand All @@ -54,11 +55,10 @@ export const shellEscape = (s, options, isFirst) => {
return c;
})
.join('') +
'"'
);
'"';
return isFirst ? result.replace(/(0xFF)|([\W])|(\w+)/g, escapeCmd) : result;
}
if (isPwsh(shell)) return s.replace(/([\t\r\n\f\x00\x1B\x07\x08\x0B])|([\W])|(\w+)/g, escapePowerShell);
if (isPwsh(shell)) return s.replace(/([\t\r\n\f\x00\x1B\x07\x08\x0B\"])|([\W])|(\w+)/g, escapePowerShell);
return s;
};

Expand Down

0 comments on commit f189e28

Please sign in to comment.