Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/node_task_runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,10 @@ std::string EscapeShell(const std::string_view input) {
escaped = std::regex_replace(escaped, leadingQuotePairs, "");
escaped = std::regex_replace(escaped, tripleSingleQuote, "\\\"");
#else
// Replace single quotes("'") with "\\'" and wrap the result
// Replace single quotes("'") with `'"'"'` and wrap the result
// in single quotes.
std::string escaped =
std::regex_replace(std::string(input), std::regex("'"), "\\'");
std::regex_replace(std::string(input), std::regex("'"), "'\"'\"'");
escaped = "'" + escaped + "'";
// Remove excessive quote pairs and handle edge cases
static const std::regex tripleSingleQuote("\\\\'''");
Expand Down
6 changes: 3 additions & 3 deletions test/cctest/test_node_task_runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ TEST_F(TaskRunnerTest, EscapeShell) {
{"test words", "'test words'"},
{"$1", "'$1'"},
{"\"$1\"", "'\"$1\"'"},
{"'$1'", "'\\'$1\\''"},
{"'$1'", "\"'\"'$1'\"'\"''"},
{"\\$1", "'\\$1'"},
{"--arg=\"$1\"", "'--arg=\"$1\"'"},
{"--arg=node exec -c \"$1\"", "'--arg=node exec -c \"$1\"'"},
{"--arg=node exec -c '$1'", "'--arg=node exec -c \\'$1\\''"},
{"'--arg=node exec -c \"$1\"'", "'\\'--arg=node exec -c \"$1\"\\''"}
{"--arg=node exec -c '$1'", "'--arg=node exec -c '\"'\"'$1'\"'\"''"},
{"'--arg=node exec -c \"$1\"'", "\"'\"'--arg=node exec -c \"$1\"'\"'\"''"}
#endif
};

Expand Down
1 change: 1 addition & 0 deletions test/fixtures/run-script/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"custom-env-windows": "custom-env.bat",
"path-env": "path-env",
"path-env-windows": "path-env.bat",
"repeat-args": "node repeat-args.js",
"special-env-variables": "special-env-variables",
"special-env-variables-windows": "special-env-variables.bat",
"pwd": "pwd",
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/run-script/repeat-args.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

console.log(JSON.stringify(process.argv.slice(2)));
14 changes: 14 additions & 0 deletions test/parallel/test-node-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,20 @@
assert.strictEqual(child.code, 0);
});

it('handles positional arguments with quotes', async () => {
const child = await common.spawnPromisified(
process.execPath,
[ '--run', 'repeat-args', '--', 'I think therefore I\'m'],
{ cwd: fixtures.path('run-script') },
);
assert.deepStrictEqual(child, {

Check failure on line 165 in test/parallel/test-node-run.js

View workflow job for this annotation

GitHub Actions / x86_64-linux: with shared libraries

--- stdout --- Test failure: 'handles positional arguments with quotes' Location: test/parallel/test-node-run.js:159:3 AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal: + actual - expected { + code: 1, - code: 0, signal: null, + stderr: '/bin/sh: 1: node: not found\n', + stdout: '' - stderr: '', - stdout: `["I think therefore I'm"]\n` } at TestContext.<anonymous> (/home/runner/work/_temp/node-v27.0.0-nightly2026-06-238a0542c7f8-slim/test/parallel/test-node-run.js:165:12) at process.processTicksAndRejections (node:internal/process/task_queues:104:5) at async Test.run (node:internal/test_runner/test:1389:7) at async Suite.processPendingSubtests (node:internal/test_runner/test:960:7) { generatedMessage: true, code: 'ERR_ASSERTION', actual: [Object], expected: [Object], operator: 'deepStrictEqual', diff: 'simple' } Command: out/Release/node --test-reporter=./test/common/test-error-reporter.js --test-reporter-destination=stdout /home/runner/work/_temp/node-v27.0.0-nightly2026-06-238a0542c7f8-slim/test/parallel/test-node-run.js

Check failure on line 165 in test/parallel/test-node-run.js

View workflow job for this annotation

GitHub Actions / aarch64-darwin: with shared libraries

--- stdout --- Test failure: 'handles positional arguments with quotes' Location: test/parallel/test-node-run.js:159:3 AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal: + actual - expected { + code: 1, - code: 0, signal: null, + stderr: '/bin/sh: node: command not found\n', + stdout: '' - stderr: '', - stdout: `["I think therefore I'm"]\n` } at TestContext.<anonymous> (/Users/runner/work/_temp/node-v27.0.0-nightly2026-06-238a0542c7f8-slim/test/parallel/test-node-run.js:165:12) at async Test.run (node:internal/test_runner/test:1389:7) at async Suite.processPendingSubtests (node:internal/test_runner/test:960:7) { generatedMessage: true, code: 'ERR_ASSERTION', actual: [Object], expected: [Object], operator: 'deepStrictEqual', diff: 'simple' } Command: out/Release/node --test-reporter=./test/common/test-error-reporter.js --test-reporter-destination=stdout /Users/runner/work/_temp/node-v27.0.0-nightly2026-06-238a0542c7f8-slim/test/parallel/test-node-run.js

Check failure on line 165 in test/parallel/test-node-run.js

View workflow job for this annotation

GitHub Actions / x86_64-darwin: with shared libraries

--- stdout --- Test failure: 'handles positional arguments with quotes' Location: test/parallel/test-node-run.js:159:3 AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal: + actual - expected { + code: 1, - code: 0, signal: null, + stderr: '/bin/sh: node: command not found\n', + stdout: '' - stderr: '', - stdout: `["I think therefore I'm"]\n` } at TestContext.<anonymous> (/Users/runner/work/_temp/node-v27.0.0-nightly2026-06-238a0542c7f8-slim/test/parallel/test-node-run.js:165:12) at async Test.run (node:internal/test_runner/test:1389:7) at async Suite.processPendingSubtests (node:internal/test_runner/test:960:7) { generatedMessage: true, code: 'ERR_ASSERTION', actual: [Object], expected: [Object], operator: 'deepStrictEqual', diff: 'simple' } Command: out/Release/node --test-reporter=./test/common/test-error-reporter.js --test-reporter-destination=stdout /Users/runner/work/_temp/node-v27.0.0-nightly2026-06-238a0542c7f8-slim/test/parallel/test-node-run.js

Check failure on line 165 in test/parallel/test-node-run.js

View workflow job for this annotation

GitHub Actions / aarch64-linux: with shared openssl-3.6.2

--- stdout --- Test failure: 'handles positional arguments with quotes' Location: test/parallel/test-node-run.js:159:3 AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal: + actual - expected { + code: 1, - code: 0, signal: null, + stderr: '/bin/sh: 1: node: not found\n', + stdout: '' - stderr: '', - stdout: `["I think therefore I'm"]\n` } at TestContext.<anonymous> (/home/runner/work/_temp/node-v27.0.0-nightly2026-06-238a0542c7f8-slim/test/parallel/test-node-run.js:165:12) at process.processTicksAndRejections (node:internal/process/task_queues:104:5) at async Test.run (node:internal/test_runner/test:1389:7) at async Suite.processPendingSubtests (node:internal/test_runner/test:960:7) { generatedMessage: true, code: 'ERR_ASSERTION', actual: [Object], expected: [Object], operator: 'deepStrictEqual', diff: 'simple' } Command: out/Release/node --test-reporter=./test/common/test-error-reporter.js --test-reporter-destination=stdout /home/runner/work/_temp/node-v27.0.0-nightly2026-06-238a0542c7f8-slim/test/parallel/test-node-run.js

Check failure on line 165 in test/parallel/test-node-run.js

View workflow job for this annotation

GitHub Actions / aarch64-linux: with shared boringssl-0.20260526.0

--- stdout --- Test failure: 'handles positional arguments with quotes' Location: test/parallel/test-node-run.js:159:3 AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal: + actual - expected { + code: 1, - code: 0, signal: null, + stderr: '/bin/sh: 1: node: not found\n', + stdout: '' - stderr: '', - stdout: `["I think therefore I'm"]\n` } at TestContext.<anonymous> (/home/runner/work/_temp/node-v27.0.0-nightly2026-06-238a0542c7f8-slim/test/parallel/test-node-run.js:165:12) at async Test.run (node:internal/test_runner/test:1389:7) at async Suite.processPendingSubtests (node:internal/test_runner/test:960:7) { generatedMessage: true, code: 'ERR_ASSERTION', actual: [Object], expected: [Object], operator: 'deepStrictEqual', diff: 'simple' } Command: out/Release/node --test-reporter=./test/common/test-error-reporter.js --test-reporter-destination=stdout /home/runner/work/_temp/node-v27.0.0-nightly2026-06-238a0542c7f8-slim/test/parallel/test-node-run.js

Check failure on line 165 in test/parallel/test-node-run.js

View workflow job for this annotation

GitHub Actions / aarch64-linux: with shared openssl-3.5.7

--- stdout --- Test failure: 'handles positional arguments with quotes' Location: test/parallel/test-node-run.js:159:3 AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal: + actual - expected { + code: 1, - code: 0, signal: null, + stderr: '/bin/sh: 1: node: not found\n', + stdout: '' - stderr: '', - stdout: `["I think therefore I'm"]\n` } at TestContext.<anonymous> (/home/runner/work/_temp/node-v27.0.0-nightly2026-06-238a0542c7f8-slim/test/parallel/test-node-run.js:165:12) at process.processTicksAndRejections (node:internal/process/task_queues:104:5) at async Test.run (node:internal/test_runner/test:1389:7) at async Suite.processPendingSubtests (node:internal/test_runner/test:960:7) { generatedMessage: true, code: 'ERR_ASSERTION', actual: [Object], expected: [Object], operator: 'deepStrictEqual', diff: 'simple' } Command: out/Release/node --test-reporter=./test/common/test-error-reporter.js --test-reporter-destination=stdout /home/runner/work/_temp/node-v27.0.0-nightly2026-06-238a0542c7f8-slim/test/parallel/test-node-run.js

Check failure on line 165 in test/parallel/test-node-run.js

View workflow job for this annotation

GitHub Actions / aarch64-linux: with shared openssl-1.1.1w

--- stdout --- Test failure: 'handles positional arguments with quotes' Location: test/parallel/test-node-run.js:159:3 AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal: + actual - expected { + code: 1, - code: 0, signal: null, + stderr: '/bin/sh: 1: node: not found\n', + stdout: '' - stderr: '', - stdout: `["I think therefore I'm"]\n` } at TestContext.<anonymous> (/home/runner/work/_temp/node-v27.0.0-nightly2026-06-238a0542c7f8-slim/test/parallel/test-node-run.js:165:12) at async Test.run (node:internal/test_runner/test:1389:7) at async Suite.processPendingSubtests (node:internal/test_runner/test:960:7) { generatedMessage: true, code: 'ERR_ASSERTION', actual: [Object], expected: [Object], operator: 'deepStrictEqual', diff: 'simple' } Command: out/Release/node --test-reporter=./test/common/test-error-reporter.js --test-reporter-destination=stdout /home/runner/work/_temp/node-v27.0.0-nightly2026-06-238a0542c7f8-slim/test/parallel/test-node-run.js

Check failure on line 165 in test/parallel/test-node-run.js

View workflow job for this annotation

GitHub Actions / aarch64-linux: with shared openssl-3.0.21

--- stdout --- Test failure: 'handles positional arguments with quotes' Location: test/parallel/test-node-run.js:159:3 AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal: + actual - expected { + code: 1, - code: 0, signal: null, + stderr: '/bin/sh: 1: node: not found\n', + stdout: '' - stderr: '', - stdout: `["I think therefore I'm"]\n` } at TestContext.<anonymous> (/home/runner/work/_temp/node-v27.0.0-nightly2026-06-238a0542c7f8-slim/test/parallel/test-node-run.js:165:12) at process.processTicksAndRejections (node:internal/process/task_queues:104:5) at async Test.run (node:internal/test_runner/test:1389:7) at async Suite.processPendingSubtests (node:internal/test_runner/test:960:7) { generatedMessage: true, code: 'ERR_ASSERTION', actual: [Object], expected: [Object], operator: 'deepStrictEqual', diff: 'simple' } Command: out/Release/node --test-reporter=./test/common/test-error-reporter.js --test-reporter-destination=stdout /home/runner/work/_temp/node-v27.0.0-nightly2026-06-238a0542c7f8-slim/test/parallel/test-node-run.js

Check failure on line 165 in test/parallel/test-node-run.js

View workflow job for this annotation

GitHub Actions / aarch64-linux: with shared openssl-4.0.1

--- stdout --- Test failure: 'handles positional arguments with quotes' Location: test/parallel/test-node-run.js:159:3 AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal: + actual - expected { + code: 1, - code: 0, signal: null, + stderr: '/bin/sh: 1: node: not found\n', + stdout: '' - stderr: '', - stdout: `["I think therefore I'm"]\n` } at TestContext.<anonymous> (/home/runner/work/_temp/node-v27.0.0-nightly2026-06-238a0542c7f8-slim/test/parallel/test-node-run.js:165:12) at process.processTicksAndRejections (node:internal/process/task_queues:104:5) at async Test.run (node:internal/test_runner/test:1389:7) at async Suite.processPendingSubtests (node:internal/test_runner/test:960:7) { generatedMessage: true, code: 'ERR_ASSERTION', actual: [Object], expected: [Object], operator: 'deepStrictEqual', diff: 'simple' } Command: out/Release/node --test-reporter=./test/common/test-error-reporter.js --test-reporter-destination=stdout /home/runner/work/_temp/node-v27.0.0-nightly2026-06-238a0542c7f8-slim/test/parallel/test-node-run.js
stdout: `["I think therefore I'm"]\n`,
stderr: '',
code: 0,
signal: null,
});
});

it('should set PATH environment variable with paths appended with node_modules/.bin', async () => {
const child = await common.spawnPromisified(
process.execPath,
Expand Down
Loading