mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Merge pull request #20393 from xdelaruelle/skip-shell-func
Skip shell functions when parsing env
This commit is contained in:
@@ -121,13 +121,22 @@ async function getEnvFromShell(env) {
|
||||
}
|
||||
|
||||
let result = {};
|
||||
let skip = false;
|
||||
for (let line of stdout.split('\n')) {
|
||||
if (line.includes('=')) {
|
||||
// start of shell function definition: skip full definition
|
||||
if (line.includes('=() {')) {
|
||||
skip = true;
|
||||
}
|
||||
if (!skip && line.includes('=')) {
|
||||
let components = line.split('=');
|
||||
let key = components.shift();
|
||||
let value = components.join('=');
|
||||
result[key] = value;
|
||||
}
|
||||
// end of shell function definition
|
||||
if (line === '}') {
|
||||
skip = false;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user