Skip to content

Commit a60adf0

Browse files
committed
Escape pkgx +pkg; Fixes #902
1 parent 9bd20fa commit a60adf0

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/modes/env.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ Deno.test("env.ts", async () => {
1010

1111
const stub1 = mock.stub(_internals, "install", () => Promise.resolve({installations: [], pkgenv: []}))
1212
const stub2 = mock.stub(_internals, "construct_env", () => Promise.resolve({
13-
PATH: "/a", FOO: "bar"
13+
PATH: "/a", FOO: "bar baz"
1414
}))
1515

1616
try {
1717
const rv = await specimen({ pkgs: [pkg], update: false, logger })
1818
assertEquals(rv, undent`
1919
PATH=/a
20-
FOO=bar
20+
FOO="bar baz"
2121
`)
2222
} finally {
2323
stub1.restore()

src/modes/env.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import escape_if_necessary from "../utils/sh-escape.ts"
12
import construct_env from "../prefab/construct-env.ts"
23
import install, { Logger } from "../prefab/install.ts"
34
import { PackageRequirement } from "pkgx"
@@ -11,7 +12,7 @@ export default async function({ pkgs, ...opts }: {
1112
const installations = await install(pkgs, opts)
1213
const env = await construct_env(installations)
1314
return Object.entries(env).map(([key, value]) =>
14-
`${key}=${value}`
15+
`${key}=${escape_if_necessary(value)}`
1516
).join("\n")
1617
}
1718

0 commit comments

Comments
 (0)