Skip to content

Commit cc9837c

Browse files
fix(shared): login-shell environment probe ignores DEBUG trap output
A DEBUG trap that echoes $BASH_COMMAND into the terminal title (a common .bashrc snippet) printed every probe command, markers included, before it ran, so PATH and XDG_DATA_HOME came back as trap noise. The probe now clears the DEBUG trap before printing any marker. Nushell has no DEBUG trap and is left unchanged. Fixes #32637 Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent c0fc3d3 commit cc9837c

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎packages/shared/src/shell.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ export function buildEnvironmentCaptureCommand(
215215
const executableName = NodePath.basename(shell).toLowerCase();
216216
const isNushell = executableName.startsWith("nu");
217217

218-
return names
218+
const capture = names
219219
.map((name) => {
220220
if (!SHELL_ENV_NAME_PATTERN.test(name)) {
221221
throw new Error(`Unsupported environment variable name: ${name}`);
@@ -249,6 +249,9 @@ export function buildEnvironmentCaptureCommand(
249249
].join("; ");
250250
})
251251
.join("; ");
252+
253+
// A DEBUG trap that echoes each command (e.g. into the terminal title) would print the markers.
254+
return isNushell ? capture : `trap - DEBUG 2>/dev/null; ${capture}`;
252255
}
253256

254257
function buildWindowsEnvironmentCaptureCommand(names: ReadonlyArray<string>): string {

0 commit comments

Comments
 (0)