From 6d1ebda50e5c5ffdaf62f4fe18627254c50ae1aa Mon Sep 17 00:00:00 2001 From: koneu Date: Wed, 2 Apr 2025 17:02:16 +0200 Subject: [PATCH 1/2] include args and env when from automationProfile --- src/util.ts | 58 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 11 deletions(-) diff --git a/src/util.ts b/src/util.ts index 9bef4a04..a30970be 100644 --- a/src/util.ts +++ b/src/util.ts @@ -399,43 +399,79 @@ export function spawnChildProcess( `integrated.automationShell.${shellPlatform}` ); // and replaced with automationProfile - if (typeof shellType === "object") { - shellType = shellType["path"]; - } - // Final quoting decisions for process name and args before being executed. let qProcessName: string = options.ensureQuoted ? quoteStringIfNeeded(processName) : processName; + let qArgs: string[] = options.ensureQuoted ? args.map((arg) => { return quoteStringIfNeeded(arg); }) : args; + let lprocessname: string; + let largs: string[]; + let lenv: EnvironmentVariables; + let lshell: string | boolean; + let lshell_describe: string; + if (typeof shellType !== "object") { + // no profile specified -> start process on default shell + lprocessname = qProcessName; + largs = qArgs; + lshell = true; + lshell_describe = "default"; + lenv = finalEnvironment; + } else { + const profile_args = (shellType["args"] as string[]) ?? []; + const profile_env = (shellType["env"] as EnvironmentVariables) ?? {}; + + if (profile_args.length > 0) { + // automation profile with args specified, child_process.spawn dow not support + // args for shell so have to start the process in the specified shell manually + lprocessname = shellType["path"]; + largs = [ + profile_args.join(" "), + ' -c "', + qProcessName + " " + qArgs.join(" ") + '"', + ]; + lshell = true; + lshell_describe = "default"; + lenv = { ...finalEnvironment, ...profile_env }; + } else { + // start process on specified shell + lprocessname = qProcessName; + largs = qArgs; + lshell = shellType["path"]; + lshell_describe = shellType["path"]; + lenv = { ...finalEnvironment, ...profile_env }; + } + } + if (options.ensureQuoted) { logger.message( localize( "utils.quoting", "Spawning child process with:\n process name: {0}\n process args: {1}\n working directory: {2}\n shell type: {3}", - qProcessName, - qArgs.join(","), + lprocessname, + largs.join(","), options.workingDirectory, - shellType || "default" + lshell_describe ), "Debug" ); } const child: child_process.ChildProcess = child_process.spawn( - qProcessName, - qArgs, + lprocessname, + largs, { cwd: options.workingDirectory, - shell: shellType || true, - env: finalEnvironment, + shell: lshell, + env: lenv, } ); + if (child.pid) { make.setCurPID(child.pid); } From 8618089823d3783a8cebb09e92f4af7d803f749b Mon Sep 17 00:00:00 2001 From: koneu Date: Wed, 2 Apr 2025 17:02:36 +0200 Subject: [PATCH 2/2] not using atomation profile commands executed via bas, that themself start a bash otherwise the call from parser will not work --- src/util.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/util.ts b/src/util.ts index a30970be..c54f0162 100644 --- a/src/util.ts +++ b/src/util.ts @@ -415,8 +415,13 @@ export function spawnChildProcess( let lenv: EnvironmentVariables; let lshell: string | boolean; let lshell_describe: string; - if (typeof shellType !== "object") { + if ( + typeof shellType !== "object" || + qProcessName.startsWith("cmd") || + qProcessName.startsWith("/bin/bash") + ) { // no profile specified -> start process on default shell + // also not trying to execute other shell commands in the automationShell, to avoid casting issues lprocessname = qProcessName; largs = qArgs; lshell = true;