Commit da62d1c
committed
fix(remote): fix zsh @shell bootstrap failure and improve error messages
Root cause of "SSH exit code: 1" when using @shell zsh:
1. TERM=dumb in non-interactive SSH sessions caused prompt tools
(starship, etc.) to fail during zsh initialization
2. ~/.zshrc defines interactive hooks (precmd/preexec/chpwd functions
and hook arrays). After sourcing ~/.zshrc and re-enabling set -e,
these hooks would run and fail in the non-interactive errexit
context, causing the entire script to exit with code 1 before
any user commands executed. The previous code cleaned hooks AFTER
set -e, which was too late.
Fixes:
- executor.py: Restructure zsh bootstrap to clean interactive hooks
(unset precmd_functions/preexec_functions/chpwd_functions and
unfunction the hook functions) AFTER sourcing ~/.zshrc but BEFORE
re-enabling set -e, preventing hooks from triggering in errexit mode
- executor.py: Set safe TERM=xterm-256color early in bootstrap to
avoid dumb terminal issues with prompt initialization tools
- executor.py: Rewrite _zsh_cleanup_interactive_hooks() to safely
check for function existence with (( $+functions[name] )) before
unfunctioning, avoiding errors when functions do not exist
- executor.py: Enhance _build_remote_error_message() to show failed
command, command output, stderr details, and last 20 lines of
stdout instead of just "SSH exit code: N"
- executor.py: Pass cleaned_stdout to error message builder for
complete failure context
- executor.py: Add bootstrap command patterns to _is_trace_noise()
to filter unset/unfunction/exec redirection commands from user-
visible command logs
- runner.py: Remove duplicate error message printing in
_execute_remote_block_sequential (already printed by
_execute_block_with_sequential_output)
- tests: Update unit tests and BDD feature expectations to match
new zsh bootstrap format
All tests pass: 193 pytest + 30 BDD scenarios, lint, and typecheck.1 parent f6c155c commit da62d1c
4 files changed
Lines changed: 81 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
132 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
133 | 137 | | |
134 | | - | |
135 | | - | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
136 | 142 | | |
137 | 143 | | |
138 | 144 | | |
139 | 145 | | |
140 | | - | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
141 | 160 | | |
142 | 161 | | |
143 | 162 | | |
144 | 163 | | |
145 | 164 | | |
146 | 165 | | |
147 | 166 | | |
148 | | - | |
149 | | - | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
150 | 178 | | |
151 | | - | |
152 | 179 | | |
153 | 180 | | |
154 | 181 | | |
155 | 182 | | |
| 183 | + | |
| 184 | + | |
156 | 185 | | |
157 | 186 | | |
158 | 187 | | |
| |||
227 | 256 | | |
228 | 257 | | |
229 | 258 | | |
230 | | - | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
231 | 265 | | |
232 | 266 | | |
| 267 | + | |
233 | 268 | | |
234 | 269 | | |
235 | 270 | | |
236 | 271 | | |
| 272 | + | |
237 | 273 | | |
238 | 274 | | |
239 | 275 | | |
| 276 | + | |
| 277 | + | |
240 | 278 | | |
| 279 | + | |
| 280 | + | |
241 | 281 | | |
242 | | - | |
| 282 | + | |
243 | 283 | | |
244 | | - | |
245 | | - | |
246 | | - | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
247 | 297 | | |
248 | 298 | | |
249 | 299 | | |
| |||
293 | 343 | | |
294 | 344 | | |
295 | 345 | | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
296 | 349 | | |
297 | 350 | | |
298 | 351 | | |
| |||
595 | 648 | | |
596 | 649 | | |
597 | 650 | | |
598 | | - | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
599 | 656 | | |
600 | 657 | | |
601 | 658 | | |
| |||
634 | 691 | | |
635 | 692 | | |
636 | 693 | | |
637 | | - | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
638 | 697 | | |
639 | 698 | | |
640 | 699 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1001 | 1001 | | |
1002 | 1002 | | |
1003 | 1003 | | |
1004 | | - | |
1005 | | - | |
| 1004 | + | |
| 1005 | + | |
1006 | 1006 | | |
1007 | 1007 | | |
1008 | 1008 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
804 | 804 | | |
805 | 805 | | |
806 | 806 | | |
807 | | - | |
808 | | - | |
809 | | - | |
810 | | - | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
811 | 811 | | |
812 | 812 | | |
813 | 813 | | |
| |||
0 commit comments