-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reland: Support multi-line environment variables
A standard Fedora install comes with 2 multiple line environment variables. Since `env` was previously split by '\n' this would break them, causing errors in the output pane and in terminals launched through the file explorer (see #3495). The original commit didn't work on OSX since `env` does not support the --null arg. This version can fail if a command line arg's 1+th line looks like an environment variable. There is no easy way to prevent this since `process.env` cannot be leveraged. Since the likelyhood of this happening is small, plus the chance of it causing any significant issue is also small it's a reasonable compromise for the time being. Fixes #3928 Fixes #4672
- Loading branch information
Showing
2 changed files
with
78 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
'use strict'; | ||
|
||
import * as assert from 'assert'; | ||
import env = require('vs/base/node/env'); | ||
|
||
suite('Env', () => { | ||
test('Parses multi-line environment variables at end of env', function(done: () => void) { | ||
let vars = env.parseEnvOutput("a=first\nb=multiple\nlines"); | ||
|
||
assert.equal(Object.keys(vars).length, 2); | ||
assert.equal(vars['a'], "first"); | ||
assert.equal(vars['b'], "multiple\nlines"); | ||
|
||
done(); | ||
}); | ||
|
||
test('Parses multi-line environment variables at start of env', function(done: () => void) { | ||
let vars = env.parseEnvOutput("a=multiple\nlines\nb=second"); | ||
|
||
assert.equal(Object.keys(vars).length, 2); | ||
assert.equal(vars['a'], "multiple\nlines"); | ||
assert.equal(vars['b'], "second"); | ||
|
||
done(); | ||
}); | ||
|
||
test('Parses complex multi-line environment variables', function(done: () => void) { | ||
let vars = env.parseEnvOutput("a=1\nb=\n23 =4\n_5c=56\n d=7\nE =8"); | ||
|
||
assert.equal(Object.keys(vars).length, 3); | ||
assert.equal(vars['a'], "1"); | ||
assert.equal(vars['b'], "\n23 =4"); | ||
assert.equal(vars['_5c'], "56\n d=7\nE =8"); | ||
|
||
done(); | ||
}); | ||
}); |