Skip to content

Commit 3bb1578

Browse files
authored
Spawn .bat/.cmd DebugAdapterExecutables with shell=true (microsoft#224320)
* Spawn .bat DAs with shell=true * Also escape args * And .cmd * escape argument properly * Don't escape \
1 parent 52b2f67 commit 3bb1578

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/vs/workbench/contrib/debug/node/debugAdapter.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,26 @@ export class ExecutableDebugAdapter extends StreamDebugAdapter {
222222
throw new Error(nls.localize('unableToLaunchDebugAdapterNoArgs', "Unable to launch debug adapter."));
223223
}
224224
} else {
225+
let spawnCommand = command;
226+
let spawnArgs = args;
225227
const spawnOptions: cp.SpawnOptions = {
226228
env: env
227229
};
228230
if (options.cwd) {
229231
spawnOptions.cwd = options.cwd;
230232
}
231-
this.serverProcess = cp.spawn(command, args, spawnOptions);
233+
if (platform.isWindows && (command.endsWith('.bat') || command.endsWith('.cmd'))) {
234+
// https://github.com/microsoft/vscode/issues/224184
235+
spawnOptions.shell = true;
236+
spawnCommand = `"${command}"`;
237+
spawnArgs = args.map(a => {
238+
a = a.replace(/"/g, '\\"'); // Escape existing double quotes with \
239+
// Wrap in double quotes
240+
return `"${a}"`;
241+
});
242+
}
243+
244+
this.serverProcess = cp.spawn(spawnCommand, spawnArgs, spawnOptions);
232245
}
233246

234247
this.serverProcess.on('error', err => {

0 commit comments

Comments
 (0)