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 <frantisek.hrbata@espressif.com>
This commit is contained in:
Frantisek Hrbata 2024-09-17 09:34:32 +02:00 committed by Marek Fiala
parent eb606b9777
commit 2109f81102

View File

@ -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()