The best way to control Claude Code, Codex and more from any computer or phone
fix(ssh): preserve literal home paths in Include expansion (#33288)
Co-authored-by: Simone <185146821+Lucenx9@users.noreply.github.com> Co-authored-by: maria-rcks <maria@kuuro.net>
Simone committed
Nov 15, 2026 at 10:16 UTC
c8a1b5ff0b457860a7b8daad5963026cef96ac63
2 files changed
+10
-4
packages/ssh/src/config.test.ts
+9
-3
@@ -14,14 +14,14 @@ function makeTempHomeDir() {
14
}
15
16
describe("ssh config", () => {
17
- it.effect("deduplicates hosts through quoted, escaped, and Unicode Includes", () =>
17
+ it.effect("deduplicates hosts through quoted, escaped, Unicode, and home-relative Includes", () =>
18
Effect.gen(function* () {
19
const fs = yield* FileSystem.FileSystem;
20
const path = yield* Path.Path;
21
- const homeDir = yield* makeTempHomeDir();
21
+ const homeDir = path.join(yield* makeTempHomeDir(), "home-$&-$$");
22
const sshDir = path.join(homeDir, ".ssh");
23
const quotedDir = path.join(homeDir, "quoted dir");
24
- yield* fs.makeDirectory(sshDir);
24
+ yield* fs.makeDirectory(sshDir, { recursive: true });
25
yield* fs.makeDirectory(quotedDir);
26
yield* fs.writeFileString(
27
path.join(quotedDir, "team#1=a.conf"),
@@ -43,11 +43,16 @@ describe("ssh config", () => {
43
`Host unicode-${index}\n HostName unicode-${index}.example.com\nHost *\n`,
44
);
45
}
46
+ yield* fs.writeFileString(
47
+ path.join(sshDir, "home.conf"),
48
+ "Host home-relative\n HostName home.example.com\nHost *\n",
49
+ );
50
yield* fs.writeFileString(
51
path.join(sshDir, "config"),
52
[
53
`Include "${path.join(quotedDir, "team#1=a.conf")}" # comment`,
54
`Include ${path.join(homeDir, "escaped space.conf").replaceAll(" ", "\\ ")}`,
55
+ "Include ~/.ssh/home.conf",
56
`Include ${unicodeFiles.map((file, index) => (index % 2 === 0 ? file : `"${file}"`)).join("\t")}`,
57
].join("\n") + "\r",
58
);
@@ -62,6 +67,7 @@ describe("ssh config", () => {
67
hosts.map((host) => [host.alias, host.hostname, host.source]),
68
[
69
["escaped", "escaped.example.com", "ssh-config"],
70
+ ["home-relative", "home.example.com", "ssh-config"],
71
["quoted", "quoted.example.com", "ssh-config"],
72
...unicodeFiles.map((_, index) => [
73
`unicode-${index}`,
packages/ssh/src/config.ts
+1
-1
@@ -67,7 +67,7 @@ function parseSshConfigLine(line: string) {
67
}
68
69
function expandHomePath(input: string, homeDir: string): string {
70
- return input.replace(/^~(?=$|\/|\\)/u, homeDir);
70
+ return input.replace(/^~(?=$|\/|\\)/u, () => homeDir);
71
}
72
73
const resolveSshConfigIncludePattern = Effect.fnUntraced(function* (