Skip to content

Commit ae64a68

Browse files
committed
fix(ssh): record the archive lock owner's real PID
String.replaceAll treats $$ in a string replacement as an escaped $, so the runner embedded in the SSH launch script wrote a literal $ as the archive lock owner. A replacer function keeps the value literal.
1 parent 921cb3c commit ae64a68

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,12 @@ describe("ssh tunnel scripts", () => {
242242
assert.notInclude(script, "npx");
243243
});
244244

245+
it("embeds the runner in the launch script byte for byte", () => {
246+
const runner = buildRemoteT3RunnerScript(ARCHIVE);
247+
assert.include(runner, 'printf \'%s\\n\' "$$" > "$T3_LOCK/pid.tmp"');
248+
assert.include(buildRemoteLaunchScript(ARCHIVE), runner);
249+
});
250+
245251
it("uses the remote t3 runner for launch and pairing scripts", () => {
246252
const target = {
247253
alias: "devbox",

‎packages/ssh/src/tunnel.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ function applyScriptPlaceholders(
243243
): string {
244244
let result = template;
245245
for (const [token, value] of Object.entries(replacements)) {
246-
result = result.replaceAll(`@@${token}@@`, value);
246+
// A replacer function keeps `$$` and other `$` patterns in the value literal.
247+
result = result.replaceAll(`@@${token}@@`, () => value);
247248
}
248249
return result;
249250
}

0 commit comments

Comments
 (0)