Skip to content

Commit

Permalink
de-dupe env keys
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcl committed Mar 14, 2023
1 parent 8488a58 commit d248850
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/hooks/useShellEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,12 @@ function suffixes(key: EnvKey) {

export function expand(env: Record<string, string[]>) {
let rv = ''
for (const [key, value] of Object.entries(env)) {
for (let [key, value] of Object.entries(env)) {
if (value.length == 0) continue
// so far we don’t know any situation where we want dupes
// but we've seen a few where this breaks things, notably for single value keys that have
// gotten duped
value = value.uniq()
rv += `export ${key}="${value.join(":")}"\n`
}
return rv
Expand Down

0 comments on commit d248850

Please sign in to comment.