From e8abaeb83c6e7b35b738498c3e4aec3cafcd019f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Mar 2026 13:35:25 +0000 Subject: [PATCH] Fix Python relative path issue: correct CWD for subdirectory scripts Co-authored-by: whyour <22700758+whyour@users.noreply.github.com> --- shell/otask.sh | 2 +- shell/preload/sitecustomize.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/shell/otask.sh b/shell/otask.sh index 516a9439..7d764c73 100755 --- a/shell/otask.sh +++ b/shell/otask.sh @@ -92,7 +92,7 @@ run_normal() { cd $dir_scripts local relative_path="${file_param%/*}" - if [[ ${file_param} != /* ]] && [[ ! -z ${relative_path} ]] && [[ ${file_param} =~ "/" ]]; then + if [[ ! -z ${relative_path} ]] && [[ ${file_param} =~ "/" ]]; then cd ${relative_path} file_param=${file_param/$relative_path\//} fi diff --git a/shell/preload/sitecustomize.py b/shell/preload/sitecustomize.py index f4c51dd6..51b78548 100644 --- a/shell/preload/sitecustomize.py +++ b/shell/preload/sitecustomize.py @@ -42,7 +42,7 @@ def run(): os.environ["PYTHONPATH"] = prev_pythonpath split_str = "__sitecustomize__" - file_name = sys.argv[0].replace(f"{os.getenv('dir_scripts')}/", "") + file_name = os.path.abspath(sys.argv[0]).replace(f"{os.getenv('dir_scripts')}/", "") # 创建临时文件路径 temp_file = f"/tmp/env_{os.getpid()}.json"