mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 00:20:08 +01:00
process: fix default env for process.execve
The `env` parameter for `process.execve` is documented to default to `process.env`. PR-URL: https://github.com/nodejs/node/pull/60029 Refs: https://github.com/nodejs/build/pull/4156 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
c08164d016
commit
b8ea0e8e85
|
|
@ -279,7 +279,7 @@ function wrapProcessMethods(binding) {
|
|||
return true;
|
||||
}
|
||||
|
||||
function execve(execPath, args = [], env) {
|
||||
function execve(execPath, args = [], env = process.env) {
|
||||
emitExperimentalWarning('process.execve');
|
||||
|
||||
const { isMainThread } = require('internal/worker');
|
||||
|
|
@ -301,22 +301,20 @@ function wrapProcessMethods(binding) {
|
|||
}
|
||||
|
||||
const envArray = [];
|
||||
if (env !== undefined) {
|
||||
validateObject(env, 'env');
|
||||
validateObject(env, 'env');
|
||||
|
||||
for (const { 0: key, 1: value } of ObjectEntries(env)) {
|
||||
if (
|
||||
typeof key !== 'string' ||
|
||||
typeof value !== 'string' ||
|
||||
StringPrototypeIncludes(key, '\u0000') ||
|
||||
StringPrototypeIncludes(value, '\u0000')
|
||||
) {
|
||||
throw new ERR_INVALID_ARG_VALUE(
|
||||
'env', env, 'must be an object with string keys and values without null bytes',
|
||||
);
|
||||
} else {
|
||||
ArrayPrototypePush(envArray, `${key}=${value}`);
|
||||
}
|
||||
for (const { 0: key, 1: value } of ObjectEntries(env)) {
|
||||
if (
|
||||
typeof key !== 'string' ||
|
||||
typeof value !== 'string' ||
|
||||
StringPrototypeIncludes(key, '\u0000') ||
|
||||
StringPrototypeIncludes(value, '\u0000')
|
||||
) {
|
||||
throw new ERR_INVALID_ARG_VALUE(
|
||||
'env', env, 'must be an object with string keys and values without null bytes',
|
||||
);
|
||||
} else {
|
||||
ArrayPrototypePush(envArray, `${key}=${value}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user