-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
shell option for execFileSync , the parameters cannot be obtained in the script #29466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
it's work fine in |
This command: child_process.execFileSync('./bin/test.sh', ['arg0', 'arg1'], {shell: true}) Ends up executing this (note the quotes):
Which then executes (note the lack of quotes):
Compare If you drop the I'm going to close this out because it's not a bug, just (perhaps not completely obvious) shell interaction. |
thanks as you said
l tried it too /bin/sh -c "/bin/sh -c \"./bin/webp.sh arg0 arg1\"" it work fine thank again |
That statement make some sense to me for The provided explanation suggests to me that it is expected that On a related note, the described problem does not exist with For reference, I tested this on import { execFile, execFileSync } from "node:child_process";
const stdout = execFileSync(
"echo",
["foo", "bar"],
{ shell: "/bin/bash" },
);
console.log(`execFileSync: ${stdout}`); // Outputs: "execFileSync: \n"
execFile(
"echo",
["foo", "bar"],
{ shell: "/bin/bash" },
(_, stdout) => {
console.log(`execFile: ${stdout}`); // Output: "execFile: foo bar\n"
}
); |
I can't really answer that with yes or no because it depends on the shell. For Bourne-like shells: yes.
I think you've spotted a bug. This is
Can you open a new issue for that? |
I see. Rereading everything in this thread following your comment clarified it to me. Still, I can't help but wonder if that behaviour should be fixed. What if, rather than joining the Lines 564 to 565 in b631086
we pass the individual function execFileSync(file, args, options) {
spawnSync('/bin/bash', ['-c', file, ...args], options);
} Am I missing something or would that make sense?
Done 🙂 |
@ericcornelissen - Can you reference the new issue you opened for this problem? I just ran into this problem today and think this behavior is bizarre and should be fixed. But I don't know what the 'new' issue that is tracking this problem. |
@davewichers it's #43333 (there's a reference to it just above my previous comment). The problem has been fixed for me since v18.7.0 - I don't know if the fix got backported to older LTS releases. |
Uh oh!
There was an error while loading. Please reload this page.
I'm not sure if it's a bug or whether it's the design intent.
v10.15.2
Darwin bogon 18.7.0 Darwin Kernel Version 18.7.0 x86_64
bin/test.sh
here is my debug info:
node/lib/child_process.js
Line 601 in 1a96d83
the final exec script
here is my trying

the final exec script
/bin/sh -c "./bin/test.sh arg0 arg1"
The text was updated successfully, but these errors were encountered: