Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/execution/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ const executeShellCommand = async (
// Use Bun's $ template literal to execute the command
// The nothrow() method prevents throwing on non-zero exit codes
// The quiet() method suppresses output and returns Buffers
const result = await Bun.$`sh -c ${command}`.nothrow().quiet()
const result = await Bun.$`${{ raw: command }}`.nothrow().quiet()

// Extract stdout and stderr as text
// result.stdout and result.stderr are Buffers, convert to string
Expand Down
8 changes: 4 additions & 4 deletions tests/execution.shell.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe("Shell command execution", () => {
})

it("captures stderr from failed commands", async () => {
const result = await executeCommand("sh -c 'echo error >&2; exit 1'")
const result = await executeCommand("printf 'error' 1>&2; exit 1")

expect(result.success).toBe(false)
expect(result.exitCode).toBe(1)
Expand Down Expand Up @@ -59,7 +59,7 @@ describe("Shell command execution", () => {
})

it("handles commands with environment variables", async () => {
const result = await executeCommand("TEST_VAR=hello sh -c 'echo $TEST_VAR'")
const result = await executeCommand("TEST_VAR=hello && echo $TEST_VAR")

expect(result.success).toBe(true)
expect(result.stdout).toContain("hello")
Expand Down Expand Up @@ -179,7 +179,7 @@ describe("Shell command execution", () => {

it("handles Bun shell with quiet mode", async () => {
// quiet() suppresses output, so we should get clean stdout/stderr
const result = await executeCommand("echo 'test' && echo 'error' >&2")
const result = await executeCommand("echo 'test' && printf 'error' 1>&2")

expect(result.stdout).toContain("test")
expect(result.stderr).toContain("error")
Expand Down Expand Up @@ -207,7 +207,7 @@ describe("Shell command execution", () => {
})

it("handles commands with syntax errors", async () => {
const result = await executeCommand("sh -c 'invalid syntax )'")
const result = await executeCommand("(invalid syntax")

expect(result.success).toBe(false)
expect(result.exitCode).toBeGreaterThan(0)
Expand Down