Skip to content

Commit

Permalink
Escape pkgx +pkg; Fixes pkgxdev#902
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcl committed Dec 22, 2023
1 parent 9bd20fa commit a60adf0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/modes/env.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ Deno.test("env.ts", async () => {

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

try {
const rv = await specimen({ pkgs: [pkg], update: false, logger })
assertEquals(rv, undent`
PATH=/a
FOO=bar
FOO="bar baz"
`)
} finally {
stub1.restore()
Expand Down
3 changes: 2 additions & 1 deletion src/modes/env.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import escape_if_necessary from "../utils/sh-escape.ts"
import construct_env from "../prefab/construct-env.ts"
import install, { Logger } from "../prefab/install.ts"
import { PackageRequirement } from "pkgx"
Expand All @@ -11,7 +12,7 @@ export default async function({ pkgs, ...opts }: {
const installations = await install(pkgs, opts)
const env = await construct_env(installations)
return Object.entries(env).map(([key, value]) =>
`${key}=${value}`
`${key}=${escape_if_necessary(value)}`
).join("\n")
}

Expand Down

0 comments on commit a60adf0

Please sign in to comment.