Skip to content

Commit 4cd1c0f

Browse files
committed
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 microsoft#3495). Fixes microsoft#3928
1 parent 0e1ed93 commit 4cd1c0f

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/vs/base/node/env.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export function getUserEnvironment(): TPromise<IEnv> {
1919
}
2020

2121
return new TPromise((c, e) => {
22-
let child = cp.spawn(process.env.SHELL, ['-ilc', 'env'], {
22+
// Use --null and split by '\0' as splitting by '\n' breaks multi-line environment variables
23+
let child = cp.spawn(process.env.SHELL, ['-ilc', 'env', '--null'], {
2324
detached: true,
2425
stdio: ['ignore', 'pipe', process.stderr],
2526
});
@@ -37,7 +38,7 @@ export function getUserEnvironment(): TPromise<IEnv> {
3738

3839
let result: IEnv = Object.create(null);
3940

40-
buffer.split('\n').forEach(line => {
41+
buffer.split('\0').forEach(line => {
4142
let pos = line.indexOf('=');
4243
if (pos > 0) {
4344
let key = line.substring(0, pos);

0 commit comments

Comments
 (0)