Skip to content

Commit 0cc4cb0

Browse files
authored
shellEnv: fix parsing JSON.stringify itself as the environment (#252353)
Fixes #251650
1 parent d8ffc54 commit 0cc4cb0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/vs/platform/shell/node/shellEnv.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,14 @@ async function doResolveShellEnv(logService: ILogService, token: CancellationTok
241241
return;
242242
}
243243

244-
accumulator += data.toString('utf8');
244+
accumulator += data.toString('utf8').trim();
245+
// Wait to start accumulating until we see the start of the JSON
246+
// object to avoid issues with `ps` in profile scripts (#251650)
247+
if (!accumulator.startsWith('{')) {
248+
accumulator = '';
249+
return;
250+
}
251+
245252
logService.trace('doResolveShellEnv#tryEagerParse', accumulator);
246253
tryParseEnvironment(accumulator.slice(0, -mark.length));
247254
if (didResolve) {

0 commit comments

Comments
 (0)