From 2109f81102ffaa6d77e2c897cabaf4e245dacb32 Mon Sep 17 00:00:00 2001 From: Frantisek Hrbata Date: Tue, 17 Sep 2024 09:34:32 +0200 Subject: [PATCH] fix(tools): do not include rc scripts in export script The rc scripts should be included only when a new shell is started. At present, for bash and zsh, we are also including them in the export scripts, which is incorrect and may cause recursion. Closes https://github.com/espressif/esp-idf/issues/14584 Signed-off-by: Frantisek Hrbata --- tools/export_utils/shell_types.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/export_utils/shell_types.py b/tools/export_utils/shell_types.py index c1f0c4e690..9daf91774e 100644 --- a/tools/export_utils/shell_types.py +++ b/tools/export_utils/shell_types.py @@ -72,10 +72,6 @@ class UnixShell(Shell): # Basic POSIX shells does not support autocompletion return None - def init_file(self) -> None: - with open(self.script_file_path, 'w') as fd: - self.export_file(fd) - def export_file(self, fd: TextIO) -> None: fd.write(f'{self.deactivate_cmd}\n') for var, value in self.new_esp_idf_env.items(): @@ -87,7 +83,8 @@ class UnixShell(Shell): 'Go to the project directory and run:\n\n idf.py build"\n')) def export(self) -> None: - self.init_file() + with open(self.script_file_path, 'w') as fd: + self.export_file(fd) print(f'. {self.script_file_path}') def click_ver(self) -> int: @@ -188,6 +185,10 @@ class FishShell(UnixShell): stdout: str = run_cmd([sys.executable, conf.IDF_PY], env=env) return stdout + def init_file(self) -> None: + with open(self.script_file_path, 'w') as fd: + self.export_file(fd) + def spawn(self) -> None: self.init_file() new_env = os.environ.copy()