Skip to content

Commit 6f9adc6

Browse files
fix(shared): clear the DEBUG trap in ksh too, guarded by a subshell
OpenBSD ksh exits on `trap - DEBUG`, also when installed as sh; trying it in a subshell first keeps the probe alive there and lets ksh93 drop its trap. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent e74d285 commit 6f9adc6

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎packages/shared/src/shell.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ function envCaptureEnd(name: string): string {
208208
return `__T3CODE_ENV_${name}_END__`;
209209
}
210210

211-
const DEBUG_TRAP_SHELLS = new Set(["bash", "zsh", "sh"]);
211+
const DEBUG_TRAP_SHELLS = new Set(["bash", "zsh", "sh", "ksh", "ksh93"]);
212212

213213
export function buildEnvironmentCaptureCommand(
214214
shell: string,
@@ -253,9 +253,9 @@ export function buildEnvironmentCaptureCommand(
253253
.join("; ");
254254

255255
// A DEBUG trap that echoes each command (e.g. into the terminal title) would print the markers.
256-
// Only shells that survive `trap - DEBUG`: OpenBSD ksh (loksh, oksh) exits on it.
256+
// OpenBSD ksh (also its /bin/sh) exits on `trap - DEBUG`, so try it in a subshell first.
257257
return DEBUG_TRAP_SHELLS.has(executableName)
258-
? `trap - DEBUG 2>/dev/null || true; ${capture}`
258+
? `(trap - DEBUG) 2>/dev/null && trap - DEBUG; ${capture}`
259259
: capture;
260260
}
261261

0 commit comments

Comments
 (0)