Skip to content

Commit

Permalink
Spawn .bat/.cmd DebugAdapterExecutables with shell=true (#224320)
Browse files Browse the repository at this point in the history
* Spawn .bat DAs with shell=true

* Also escape args

* And .cmd

* escape argument properly

* Don't escape \
  • Loading branch information
roblourens authored Jul 30, 2024
1 parent 52b2f67 commit 3bb1578
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/vs/workbench/contrib/debug/node/debugAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,26 @@ export class ExecutableDebugAdapter extends StreamDebugAdapter {
throw new Error(nls.localize('unableToLaunchDebugAdapterNoArgs', "Unable to launch debug adapter."));
}
} else {
let spawnCommand = command;
let spawnArgs = args;
const spawnOptions: cp.SpawnOptions = {
env: env
};
if (options.cwd) {
spawnOptions.cwd = options.cwd;
}
this.serverProcess = cp.spawn(command, args, spawnOptions);
if (platform.isWindows && (command.endsWith('.bat') || command.endsWith('.cmd'))) {

This comment has been minimized.

Copy link
@IDisposable

IDisposable Aug 6, 2024

Do we care about .BAT instead of .bat?

// https://github.com/microsoft/vscode/issues/224184
spawnOptions.shell = true;
spawnCommand = `"${command}"`;
spawnArgs = args.map(a => {
a = a.replace(/"/g, '\\"'); // Escape existing double quotes with \
// Wrap in double quotes
return `"${a}"`;
});
}

this.serverProcess = cp.spawn(spawnCommand, spawnArgs, spawnOptions);
}

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

0 comments on commit 3bb1578

Please sign in to comment.