From ebedd994dd093a6c2c584d83f66a4baa244b3e51 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 22 Nov 2025 14:47:33 +0000 Subject: [PATCH] Improve string handling for NODE_OPTIONS and PYTHONPATH Use filter(Boolean).join() to avoid extra spaces and properly handle missing environment variables. This ensures clean paths even when some variables are empty or undefined. Co-authored-by: whyour <22700758+whyour@users.noreply.github.com> --- shell/preload/sitecustomize.js | 2 +- shell/preload/sitecustomize.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/shell/preload/sitecustomize.js b/shell/preload/sitecustomize.js index ec8704f2..b8883681 100644 --- a/shell/preload/sitecustomize.js +++ b/shell/preload/sitecustomize.js @@ -43,7 +43,7 @@ function run() { // Export NODE_OPTIONS so task_before can use it for any node commands const nodeOptionsForBash = file_preload_js - ? `-r ${file_preload_js} ${PREV_NODE_OPTIONS || ''}` + ? ['-r', file_preload_js, PREV_NODE_OPTIONS].filter(Boolean).join(' ') : PREV_NODE_OPTIONS || ''; const commands = [ diff --git a/shell/preload/sitecustomize.py b/shell/preload/sitecustomize.py index 864a9026..2a4ad3d5 100644 --- a/shell/preload/sitecustomize.py +++ b/shell/preload/sitecustomize.py @@ -52,7 +52,7 @@ def run(): temp_file = f"/tmp/env_{os.getpid()}.json" # Export PYTHONPATH so task_before can use it for any python commands - pythonpath_for_bash = f"{dir_preload}:{dir_config}:{prev_pythonpath}" if dir_preload else prev_pythonpath + pythonpath_for_bash = ':'.join(filter(None, [dir_preload, dir_config, prev_pythonpath])) # 构建命令数组 commands = [