refactor: clean up shell file fetching logic

This commit is contained in:
LukeParkerDev 2026-04-02 12:49:43 +10:00
parent 4c384e4f86
commit 947a26f4df

View file

@ -124,13 +124,12 @@ export namespace Shell {
return [gitbash(), Bun.which("pwsh"), Bun.which("powershell"), process.env.COMSPEC || "cmd.exe"].filter(
Boolean,
) as string[]
} else {
try {
const text = await Bun.file("/etc/shells").text()
return text.split("\n").filter((line) => line.trim() && !line.startsWith("#"))
} catch {
return ["/bin/bash", "/bin/zsh", "/bin/sh"]
}
}
const file = Bun.file("/etc/shells")
if (await file.exists()) {
const text = await file.text()
return text.split("\n").filter((line) => line.trim() && !line.startsWith("#"))
}
return ["/bin/bash", "/bin/zsh", "/bin/sh"]
}
}