提交 05fcf172 编写于 作者: G Geir Hauge

Use different quoting for args and env

上级 8530c76f
......@@ -385,21 +385,27 @@ export function prepareCommand(args: DebugProtocol.RunInTerminalRequestArguments
break;
case ShellType.bash:
quote = (s: string) => {
return `'${s.replace(/'/g, '\'\\\'\'')}'`;
s = s.replace(/\"/g, '\\"');
return (s.indexOf(' ') >= 0 || s.indexOf('\\') >= 0) ? `"${s}"` : s;
};
hardQuote = (s: string) => {
return /[^\w%\/+=,.:^-]/.test(s) ? `'${s.replace(/'/g, '\'\\\'\'')}'` : s;
};
if (args.cwd) {
command += `cd ${quote(args.cwd)} && `;
command += `cd ${hardQuote(args.cwd)} && `;
}
if (args.env) {
command += 'env';
for (let key in args.env) {
const value = args.env[key];
if (value === null) {
command += ` -u ${quote(key)}`;
command += ` -u ${hardQuote(key)}`;
} else {
command += ` ${quote(`${key}=${value}`)}`;
command += ` ${hardQuote(`${key}=${value}`)}`;
}
}
command += ' ';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册