mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Fix test failures on darwin caused by non-GNU awk
Use printf("...%c...", 0) instead of printf("...\0...") to inject \0.
This commit is contained in:
@@ -224,7 +224,7 @@ describe('updateProcessEnv(launchEnv)', function () {
|
||||
await updateProcessEnv(process.env)
|
||||
expect(spawn.calls.length).toBe(1)
|
||||
expect(spawn.calls[0].command).toBe('/my/custom/bash')
|
||||
expect(spawn.calls[0].args).toEqual(['-ilc', 'command awk \'BEGIN{for(v in ENVIRON) printf("%s=%s\\0",v,ENVIRON[v])}\''])
|
||||
expect(spawn.calls[0].args).toEqual(['-ilc', 'command awk \'BEGIN{for(v in ENVIRON) printf("%s=%s%c", v, ENVIRON[v], 0)}\''])
|
||||
expect(process.env).toEqual({
|
||||
FOO: 'BAR=BAZ=QUUX',
|
||||
'MULTILINE\nNAME': 'multiline\nvalue',
|
||||
@@ -247,7 +247,7 @@ describe('updateProcessEnv(launchEnv)', function () {
|
||||
await updateProcessEnv(process.env)
|
||||
expect(spawn.calls.length).toBe(1)
|
||||
expect(spawn.calls[0].command).toBe('/my/custom/bash')
|
||||
expect(spawn.calls[0].args).toEqual(['-ilc', 'command awk \'BEGIN{for(v in ENVIRON) printf("%s=%s\\0",v,ENVIRON[v])}\''])
|
||||
expect(spawn.calls[0].args).toEqual(['-ilc', 'command awk \'BEGIN{for(v in ENVIRON) printf("%s=%s%c", v, ENVIRON[v], 0)}\''])
|
||||
expect(process.env).toEqual({
|
||||
FOO: 'BAR=BAZ=QUUX',
|
||||
'MULTILINE\nNAME': 'multiline\nvalue',
|
||||
|
||||
@@ -14,8 +14,9 @@ const PLATFORMS_KNOWN_TO_WORK = new Set([
|
||||
])
|
||||
|
||||
// Shell command that returns env var=value lines separated by \0s so that
|
||||
// newlines are handled properly
|
||||
const ENV_COMMAND = 'command awk \'BEGIN{for(v in ENVIRON) printf("%s=%s\\0",v,ENVIRON[v])}\''
|
||||
// newlines are handled properly. Note: need to use %c to inject the \0s
|
||||
// to work with some non GNU awks.
|
||||
const ENV_COMMAND = 'command awk \'BEGIN{for(v in ENVIRON) printf("%s=%s%c", v, ENVIRON[v], 0)}\''
|
||||
|
||||
async function updateProcessEnv (launchEnv) {
|
||||
let envToAssign
|
||||
|
||||
Reference in New Issue
Block a user