Skip to content

Commit 14490e7

Browse files
authored
fix(setup): show actual shell name instead of "unknown" for unsupported shells (#287)
## Problem When an unsupported shell (e.g. xonsh) is detected during \`sentry setup\`, the completions message shows the literal string \`unknown\` — the internal \`ShellType\` value — rather than the actual shell binary name from \`\$SHELL\`: ``` Completions: Your shell (unknown) is not directly supported ``` ## Solution Add a \`name\` field to \`ShellInfo\` populated from \`basename(\$SHELL)\` at detection time, and use it in the user-facing message: ``` Completions: Your shell (xonsh) is not directly supported Installed bash completions as a fallback: ~/.local/share/bash-completion/completions/sentry ``` When \`\$SHELL\` is unset, \`name\` falls back to the type string. ## Changes - `src/lib/shell.ts` — `name` field added to `ShellInfo`, populated in `detectShell()` - `src/commands/cli/setup.ts` — use `shell.name` in unsupported/fallback messages - `test/commands/cli/setup.test.ts` — assert on the real shell name
1 parent 30faf6f commit 14490e7

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/commands/cli/setup.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,12 @@ async function handleCompletions(
188188

189189
if (fallbackMsg) {
190190
return [
191-
`Completions: Your shell (${shell.type}) is not directly supported`,
191+
`Completions: Your shell (${shell.name}) is not directly supported`,
192192
fallbackMsg,
193193
];
194194
}
195195

196-
return [`Completions: Not supported for ${shell.type} shell`];
196+
return [`Completions: Not supported for ${shell.name} shell`];
197197
}
198198

199199
/**

src/lib/shell.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export type ShellType = "bash" | "zsh" | "fish" | "sh" | "ash" | "unknown";
1515
export type ShellInfo = {
1616
/** Detected shell type */
1717
type: ShellType;
18+
/** Display name for the shell (e.g. "xonsh", "bash"). Derived from $SHELL basename. */
19+
name: string;
1820
/** Path to shell config file, if found */
1921
configFile: string | null;
2022
/** All candidate config files for this shell */
@@ -129,11 +131,13 @@ export function detectShell(
129131
xdgConfigHome?: string
130132
): ShellInfo {
131133
const type = detectShellType(shellPath);
134+
const name = shellPath ? basename(shellPath) : type;
132135
const configCandidates = getConfigCandidates(type, homeDir, xdgConfigHome);
133136
const configFile = findExistingConfigFile(configCandidates);
134137

135138
return {
136139
type,
140+
name,
137141
configFile,
138142
configCandidates,
139143
};

test/commands/cli/setup.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ describe("sentry cli setup", () => {
323323
);
324324

325325
const combined = output.join("");
326-
expect(combined).toContain("not directly supported");
326+
expect(combined).toContain("Your shell (xonsh) is not directly supported");
327327
expect(combined).toContain("bash completions as a fallback");
328328
expect(combined).toContain("bash-completion");
329329
});
@@ -346,7 +346,7 @@ describe("sentry cli setup", () => {
346346
);
347347

348348
const combined = output.join("");
349-
expect(combined).toContain("Not supported for unknown shell");
349+
expect(combined).toContain("Not supported for xonsh shell");
350350
});
351351

352352
test("silently skips completions for sh shell", async () => {

0 commit comments

Comments
 (0)