fix(Terminal): fallback to shell (sh) if bash not exists

This commit is contained in:
Salem Yaslem 2024-09-23 15:36:36 +03:00
parent ce6a07057b
commit 979932486a

View File

@ -33,14 +33,14 @@ class TerminalOpener(QThread):
self.container_id = container_id self.container_id = container_id
def run(self): def run(self):
docker_command = f"docker exec -it {self.container_id} /bin/bash" docker_command = f"docker exec -it {self.container_id} sh -c '[ -x /bin/bash ] && exec /bin/bash || exec /bin/sh'"
system = platform.system() system = platform.system()
try: try:
if system == "Darwin": # macOS if system == "Darwin": # macOS
subprocess.Popen(['open', '-a', 'Terminal', '--', 'bash', '-c', f"{docker_command}"]) subprocess.Popen(['open', '-a', 'Terminal', '--', 'sh', '-c', f"{docker_command}"])
elif system == "Linux": elif system == "Linux":
subprocess.Popen(['x-terminal-emulator', '-e', f"bash -c '{docker_command}'"]) subprocess.Popen(['x-terminal-emulator', '-e', f'sh -c "{docker_command}"'])
elif system == "Windows": elif system == "Windows":
subprocess.Popen(['start', 'cmd', '/k', docker_command], shell=True) subprocess.Popen(['start', 'cmd', '/k', docker_command], shell=True)
else: else: