Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(shared): login-shell environment probe ignores DEBUG trap output #32646

Mergedjuliusmarmingemerged 10 commits intomain fromrefs/pull/32646/headmerged by juliusmarminge View on GitHub

Showing 2 changed files with 42 additions and 1 deletion.

x
0 of 2 viewed, 2 left
33 additions and 0 deletionspackages/shared/src/shell.test.tsModified
View file
@@ -118,6 +118,39 @@
​
+ it.runIf(NodeFS.existsSync("/bin/bash"))(
+ "ignores probe markers a bash DEBUG trap echoes into the terminal title",
+ () => {
+ const home = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-bash-env-"));
+ try {
+ const shellPath = `${NodePath.join(home, "bin")}:/usr/bin:/bin`;
+ const bashEnv = NodePath.join(home, "env.bash");
+ NodeFS.writeFileSync(
+ bashEnv,
+ [
+ `export PATH=${JSON.stringify(shellPath)}`,
+ `trap 'echo -ne "\\033]0;\${BASH_COMMAND}\\007"' DEBUG`,
+ ].join("\n"),
+ );
+​
+ expect(
+ readEnvironmentFromLoginShell(
+ "/bin/bash",
+ ["XDG_DATA_HOME", "PATH"],
+ // Non-interactive bash reads only BASH_ENV, not the host's /etc startup files that -il runs.
+ (file, [, command = ""], options) =>
+ NodeChildProcess.execFileSync(file, ["-c", command], {
+ ...options,
+ env: { HOME: home, PATH: "/usr/bin:/bin", TERM: "dumb", BASH_ENV: bashEnv },
+ }),
+ ),