From c6ff7951fad295a6dd4f0c14c1a8bbe32005ebd3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 23 Jan 2026 20:11:10 +0000 Subject: [PATCH 1/2] Initial plan From 8a56e4ea5ed4a0151d271109429385e133966822 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 23 Jan 2026 20:18:56 +0000 Subject: [PATCH 2/2] Fix parsing of environment from preconfigure script for multiline variables Use `printenv -0` instead of `printenv` on Linux/macOS to output NUL-separated environment variables. This properly handles multiline variables like bash exported functions (BASH_FUNC_*) which were previously causing syntax errors. Fixes the issue where partial function definitions were saved to the environment, causing bash to complain about syntax errors when importing function definitions. Co-authored-by: snehara99 <113148726+snehara99@users.noreply.github.com> --- src/make.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/make.ts b/src/make.ts index 308bafa3..e80620f1 100644 --- a/src/make.ts +++ b/src/make.ts @@ -1096,13 +1096,16 @@ export async function postConfigure(triggeredBy: TriggeredBy): Promise { // The input 'content' represents the output of a command that lists all the environment variables: // set on windows or printenv on linux/mac. async function applyEnvironment(content: string | undefined): Promise { - let lines: string[] = content?.split(/\r?\n/) || []; - lines.forEach((line) => { - let eqPos: number = line.search("="); - // Sometimes we get a "" line and searching for = returns -1. Skip. + // On Linux/macOS, printenv -0 outputs NUL-separated entries to support multiline values + // (e.g., BASH_FUNC_* exported functions). On Windows, 'set' outputs newline-separated entries. + const separator = process.platform === "win32" ? /\r?\n/ : /\0/; + let entries: string[] = content?.split(separator) || []; + entries.forEach((entry) => { + let eqPos: number = entry.search("="); + // Sometimes we get a "" entry and searching for = returns -1. Skip. if (eqPos !== -1) { - let envVarName: string = line.substring(0, eqPos); - let envVarValue: string = line.substring(eqPos + 1, line.length); + let envVarName: string = entry.substring(0, eqPos); + let envVarValue: string = entry.substring(eqPos + 1, entry.length); // Only save to the modified environment values if it's different than the process.env. if (!process.env[envVarName] || envVarValue !== process.env[envVarName]) { @@ -1147,7 +1150,7 @@ export async function runPrePostConfigureScript( wrapScriptContent = `source '${scriptFile}' ${ scriptArgs.length > 0 ? scriptArgs.join(" ").toString() : "" }\n`; - wrapScriptContent += `printenv > '${wrapScriptOutFile}'`; + wrapScriptContent += `printenv -0 > '${wrapScriptOutFile}'`; wrapScriptFile += ".sh"; }