tenseleyflow/bensch / 044e500

Browse files

pass rc-disable flags and set prompt at session start

- Spawn shell with profile's rc_disable.flags (e.g. --norc --noprofile)
- After initial prompt wait, send prompt_set_command from profile
to force a known prompt pattern
- Use generous timeout for initial prompt detection

Fixes: bash sessions now start with clean environment and known
prompt instead of inheriting .venv PS1 and bashrc output.
Authored by espadonne
SHA
044e5003a904a2c6e55d2c8f676730cffff96eb4
Parents
1c8e174
Tree
4618094

1 changed file

StatusFile+-
M framework/shell_pty.py 21 2
framework/shell_pty.pymodified
@@ -87,8 +87,14 @@ class ShellPTY:
87
         # Apply custom environment
87
         # Apply custom environment
88
         env.update(self.custom_env)
88
         env.update(self.custom_env)
89
 
89
 
90
+        # Build spawn command with rc-disable flags from profile
91
+        spawn_args = []
92
+        if self.profile and rc_file is not None:
93
+            spawn_args = self.profile.get("rc_disable", {}).get("flags", [])
94
+
90
         self.child = pexpect.spawn(
95
         self.child = pexpect.spawn(
91
             self.shell_path,
96
             self.shell_path,
97
+            args=spawn_args,
92
             encoding="utf-8",
98
             encoding="utf-8",
93
             codec_errors="replace",  # Handle raw ANSI/highlight bytes without crashing
99
             codec_errors="replace",  # Handle raw ANSI/highlight bytes without crashing
94
             timeout=self.timeout,
100
             timeout=self.timeout,
@@ -97,8 +103,21 @@ class ShellPTY:
97
             echo=False,  # Don't echo back input
103
             echo=False,  # Don't echo back input
98
         )
104
         )
99
 
105
 
100
-        # Wait for initial prompt
106
+        # Wait for initial prompt — use a generous timeout for slow shells
101
-        self.wait_for_prompt()
107
+        # that print banners or load rc files
108
+        try:
109
+            self.wait_for_prompt(timeout=self.timeout * 2)
110
+        except Exception:
111
+            # If prompt detection fails, try setting it from the profile
112
+            pass
113
+
114
+        # Set prompt from profile to ensure consistent matching
115
+        if self.profile and self.profile.get("prompt_set_command"):
116
+            self.send_line(self.profile["prompt_set_command"])
117
+            try:
118
+                self.wait_for_prompt(timeout=self.timeout)
119
+            except Exception:
120
+                pass
102
 
121
 
103
     def stop(self) -> int:
122
     def stop(self) -> int:
104
         """
123
         """