Skip to content

Commit b5cf4e2

Browse files
committed
fix(ssh): preserve startup quoting for Nushell accounts
1 parent 7be7267 commit b5cf4e2

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

‎packages/ssh/src/tunnel.test.ts‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,21 @@ describe("ssh tunnel scripts", () => {
178178
if (yield* fs.exists("/bin/tcsh")) {
179179
cases.push({ shell: "/bin/tcsh", outerShell: "/bin/tcsh", expected: "missing" });
180180
}
181+
const environment = yield* HostProcess.Environment;
182+
for (const folder of (environment.PATH ?? "").split(":")) {
183+
const nu = `${folder}/nu`;
184+
if (folder && (yield* fs.exists(nu))) {
185+
cases.push({ shell: nu, outerShell: nu, expected: "missing" });
186+
break;
187+
}
188+
}
181189
for (const { shell, outerShell, expected } of cases) {
182190
const child = yield* spawner.spawn(
183191
ChildProcess.make(outerShell, ["-c", remoteCommand], {
184192
env: {
193+
PATH: environment.PATH ?? "/usr/bin:/bin",
185194
HOME: directory,
195+
XDG_CONFIG_HOME: directory,
186196
SHELL: shell,
187197
BASH_ENV: startupFile,
188198
ZDOTDIR: directory,
@@ -217,7 +227,9 @@ describe("ssh tunnel scripts", () => {
217227
{ concurrency: "unbounded" },
218228
);
219229
assert.equal(Number(exitCode), 0, stderr);
220-
assert.match(stdout, new RegExp(`^${expected}:[a-f0-9]{16}$`), shell || "unset SHELL");
230+
// First-run shell messages can precede the bootstrap response.
231+
const response = stdout.trim().split(/\r?\n/u).at(-1) ?? "";
232+
assert.match(response, new RegExp(`^${expected}:[a-f0-9]{16}$`), shell || "unset SHELL");
221233
}
222234
}).pipe(Effect.provide(Layer.merge(NodeServices.layer, NodeCrypto.layer))),
223235
);

‎packages/ssh/src/tunnel.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ export const launchOrReuseRemoteServer = Effect.fn("ssh/tunnel.launchOrReuseRemo
882882
"sh",
883883
"-c",
884884
shellSingleQuote(
885-
`case "\${SHELL##*/}" in csh|tcsh) exec sh -l -s -- ${stateKey} ;; *) exec "\${SHELL:-/bin/sh}" -l -c ${shellSingleQuote(`exec sh -s -- ${stateKey}`)} ;; esac`,
885+
`case "\${SHELL##*/}" in csh|tcsh) exec sh -l -s -- ${stateKey} ;; *) exec "\${SHELL:-/bin/sh}" -l -c "exec sh -s -- ${stateKey}" ;; esac`,
886886
),
887887
],
888888
stdin: buildRemoteLaunchScript(runner),

0 commit comments

Comments
 (0)