Skip to content

Commit bf283f0

Browse files
committed
add quoting logic in runAsTask
1 parent 11bb928 commit bf283f0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/features/execution/runAsTask.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@ export async function runAsTask(
2525
): Promise<TaskExecution> {
2626
const workspace: WorkspaceFolder | TaskScope = getWorkspaceFolderOrDefault(options.project?.uri);
2727

28-
const executable =
28+
let executable =
2929
environment.execInfo?.activatedRun?.executable ?? environment.execInfo?.run.executable ?? 'python';
30+
// Quote the executable if it contains spaces and is not already quoted
31+
if (executable.includes(' ') && !(executable.startsWith('"') && executable.endsWith('"'))) {
32+
executable = `"${executable}"`;
33+
}
3034
const args = environment.execInfo?.activatedRun?.args ?? environment.execInfo?.run.args ?? [];
3135
const allArgs = [...args, ...options.args];
3236

0 commit comments

Comments
 (0)