Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 81a3055

Browse filesBrowse files
richardlauaduh95
authored andcommitted
process: fix default env for process.execve
The `env` parameter for `process.execve` is documented to default to `process.env`. PR-URL: #60029 Refs: nodejs/build#4156 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 4206406 commit 81a3055
Copy full SHA for 81a3055

File tree

Expand file treeCollapse file tree

1 file changed

+15
-17
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+15
-17
lines changed
Open diff view settings
Collapse file

‎lib/internal/process/per_thread.js‎

Copy file name to clipboardExpand all lines: lib/internal/process/per_thread.js
+15-17Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ function wrapProcessMethods(binding) {
283283
return true;
284284
}
285285

286-
function execve(execPath, args = [], env) {
286+
function execve(execPath, args = [], env = process.env) {
287287
emitExperimentalWarning('process.execve');
288288

289289
const { isMainThread } = require('internal/worker');
@@ -305,22 +305,20 @@ function wrapProcessMethods(binding) {
305305
}
306306

307307
const envArray = [];
308-
if (env !== undefined) {
309-
validateObject(env, 'env');
310-
311-
for (const { 0: key, 1: value } of ObjectEntries(env)) {
312-
if (
313-
typeof key !== 'string' ||
314-
typeof value !== 'string' ||
315-
StringPrototypeIncludes(key, '\u0000') ||
316-
StringPrototypeIncludes(value, '\u0000')
317-
) {
318-
throw new ERR_INVALID_ARG_VALUE(
319-
'env', env, 'must be an object with string keys and values without null bytes',
320-
);
321-
} else {
322-
ArrayPrototypePush(envArray, `${key}=${value}`);
323-
}
308+
validateObject(env, 'env');
309+
310+
for (const { 0: key, 1: value } of ObjectEntries(env)) {
311+
if (
312+
typeof key !== 'string' ||
313+
typeof value !== 'string' ||
314+
StringPrototypeIncludes(key, '\u0000') ||
315+
StringPrototypeIncludes(value, '\u0000')
316+
) {
317+
throw new ERR_INVALID_ARG_VALUE(
318+
'env', env, 'must be an object with string keys and values without null bytes',
319+
);
320+
} else {
321+
ArrayPrototypePush(envArray, `${key}=${value}`);
324322
}
325323
}
326324

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.