MCPcopy Index your code
hub / github.com/anomalyco/opencode / withShell

Function withShell

packages/core/test/shell.test.ts:7–21  ·  view source on GitHub ↗
(shell: string | undefined, fn: () => void | Promise<void>)

Source from the content-addressed store, hash-verified

5import { which } from "@opencode-ai/core/util/which"
6
7const withShell = async (shell: string | undefined, fn: () => void | Promise<void>) => {
8 const prev = process.env.SHELL
9 if (shell === undefined) delete process.env.SHELL
10 else process.env.SHELL = shell
11 Shell.acceptable.reset()
12 Shell.preferred.reset()
13 try {
14 await fn()
15 } finally {
16 if (prev === undefined) delete process.env.SHELL
17 else process.env.SHELL = prev
18 Shell.acceptable.reset()
19 Shell.preferred.reset()
20 }
21}
22
23describe("shell", () => {
24 test("normalizes shell names", () => {

Callers 1

shell.test.tsFile · 0.70

Calls 2

fnFunction · 0.50
resetMethod · 0.45

Tested by

no test coverage detected