fix(terminal_ops): ssh 远程命令中避免重写 /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/bin/python3.9/pip 路径
This commit is contained in:
parent
fd29b3b89c
commit
d1a9a51bb8
@ -414,12 +414,15 @@ class RunMixin:
|
||||
execution_in_container = self._will_use_container(session_override)
|
||||
python_rewrite = self.container_python_cmd if execution_in_container else self.python_cmd
|
||||
pip_rewrite = self._derive_pip_from_python(python_rewrite)
|
||||
# 统一替换 python/python3,为保障虚拟环境命中只替换独立单词
|
||||
if re.search(r"\bpython3?\b", command):
|
||||
command = re.sub(r"\bpython3?\b", python_rewrite, command)
|
||||
# 同步替换 pip/pip3,确保指向同一环境
|
||||
if re.search(r"(?<![/.\w-])pip3?\b", command):
|
||||
command = re.sub(r"(?<![/.\w-])pip3?\b", pip_rewrite, command)
|
||||
# 命令通过 ssh 在远程主机执行时,本地 Python/pip 路径对远程不适用,跳过重写
|
||||
is_remote_ssh = command.lstrip().startswith("ssh ") or re.search(r"[;&|]\s*ssh\s", command) is not None
|
||||
if not is_remote_ssh:
|
||||
# 统一替换 python/python3,为保障虚拟环境命中只替换独立单词
|
||||
if re.search(r"\bpython3?\b", command):
|
||||
command = re.sub(r"\bpython3?\b", python_rewrite, command)
|
||||
# 同步替换 pip/pip3,确保指向同一环境
|
||||
if re.search(r"(?<![/.\w-])pip3?\b", command):
|
||||
command = re.sub(r"(?<![/.\w-])pip3?\b", pip_rewrite, command)
|
||||
|
||||
# 验证命令
|
||||
valid, error = self._validate_command(command)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user