Skip to content

Commit aed9d7e

Browse files
author
Example
committed
Using rc file by default
1 parent 810d498 commit aed9d7e

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

src/wcgw/client/tools.py

+21-7
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,27 @@ def ask_confirmation(prompt: Confirmation) -> str:
106106

107107

108108
def start_shell() -> pexpect.spawn: # type: ignore
109-
SHELL = pexpect.spawn(
110-
"/bin/bash",
111-
env={**os.environ, **{"PS1": PROMPT}}, # type: ignore[arg-type]
112-
echo=False,
113-
encoding="utf-8",
114-
timeout=TIMEOUT,
115-
)
109+
try:
110+
SHELL = pexpect.spawn(
111+
"/bin/bash",
112+
env={**os.environ, **{"PS1": PROMPT}}, # type: ignore[arg-type]
113+
echo=False,
114+
encoding="utf-8",
115+
timeout=TIMEOUT,
116+
)
117+
SHELL.sendline(f"export PS1={PROMPT}")
118+
except Exception as e:
119+
traceback.print_exc()
120+
console.log(f"Error starting shell: {e}. Retrying without rc ...")
121+
122+
SHELL = pexpect.spawn(
123+
"/bin/bash --noprofile --norc",
124+
env={**os.environ, **{"PS1": PROMPT}}, # type: ignore[arg-type]
125+
echo=False,
126+
encoding="utf-8",
127+
timeout=TIMEOUT,
128+
)
129+
116130
SHELL.expect(PROMPT, timeout=TIMEOUT)
117131
SHELL.sendline("stty -icanon -echo")
118132
SHELL.expect(PROMPT, timeout=TIMEOUT)

0 commit comments

Comments
 (0)