Skip to content

Commit 1e836dc

Browse files
test(shared): run the DEBUG trap regression test without system startup files
The bash DEBUG trap regression test ran `bash -ilc` with a temporary HOME, so the host's /etc/profile, /etc/profile.d and /etc/bash.bashrc ran too. On GitHub's Ubuntu runner its ~/.bash_profile never took effect and the test failed. Run the probe command as non-interactive `bash -c` with BASH_ENV pointing at the test's file instead: that is the only startup file bash reads in that mode, and the trap still echoes every probe command. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent cc9837c commit 1e836dc

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎packages/shared/src/shell.test.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,9 @@ describe("readEnvironmentFromLoginShell", () => {
122122
const home = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-bash-env-"));
123123
try {
124124
const shellPath = `${NodePath.join(home, "bin")}:/usr/bin:/bin`;
125+
const bashEnv = NodePath.join(home, "env.bash");
125126
NodeFS.writeFileSync(
126-
NodePath.join(home, ".bash_profile"),
127+
bashEnv,
127128
[
128129
`export PATH=${JSON.stringify(shellPath)}`,
129130
`trap 'echo -ne "\\033]0;\${BASH_COMMAND}\\007"' DEBUG`,
@@ -134,10 +135,11 @@ describe("readEnvironmentFromLoginShell", () => {
134135
readEnvironmentFromLoginShell(
135136
"/bin/bash",
136137
["XDG_DATA_HOME", "PATH"],
137-
(file, args, options) =>
138-
NodeChildProcess.execFileSync(file, args, {
138+
// Non-interactive bash reads only BASH_ENV, not the host's /etc startup files that -il runs.
139+
(file, [, command = ""], options) =>
140+
NodeChildProcess.execFileSync(file, ["-c", command], {
139141
...options,
140-
env: { HOME: home, PATH: "/usr/bin:/bin", TERM: "dumb" },
142+
env: { HOME: home, PATH: "/usr/bin:/bin", TERM: "dumb", BASH_ENV: bashEnv },
141143
}),
142144
),
143145
).toEqual({ PATH: shellPath });

0 commit comments

Comments
 (0)