You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
shell option for execFileSync , the parameters cannot be obtained in the script #29466
If you drop the {shell: true} it works like (I think) you expect it to.
[...] it's not a bug, just (perhaps not completely obvious) shell interaction.
That statement make some sense to me for {shell: true}, but what about something like {shell: "/bin/bash"} - i.e. if the intend is to use a specific shell (e.g. because a specific shell's feature set is required)?
The provided explanation suggests to me that it is expected that execFileSync cannot be used with both a custom shell and arguments. is that correct, @bnoordhuis?
On a related note, the described problem does not exist with execFile. That discrepancy is unexpected to me.
For reference, I tested this on Ubuntu 20.04.4 LTS with both Node v16.15.0 and Node v18.3.0 using the script:
@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.
Activity
rambo-panda commentedon Sep 6, 2019
it's work fine in
window 10 + git bashbnoordhuis commentedon Sep 6, 2019
This command:
Ends up executing this (note the quotes):
Which then executes (note the lack of quotes):
-ctakes exactly one argument soarg0andarg1are effectively discarded here. Therefore, what's ultimately executed is this:Compare
sh -c /bin/echo no bueno, that doesn't print anything either.If you drop the
{shell: true}it works like (I think) you expect it to.I'm going to close this out because it's not a bug, just (perhaps not completely obvious) shell interaction.
rambo-panda commentedon Sep 6, 2019
@bnoordhuis
thanks
as you said
l tried it too
/bin/sh -c "/bin/sh -c \"./bin/webp.sh arg0 arg1\""it work fine
thank again
ericcornelissen commentedon Jun 5, 2022
That statement make some sense to me for
{shell: true}, but what about something like{shell: "/bin/bash"}- i.e. if the intend is to use a specific shell (e.g. because a specific shell's feature set is required)?The provided explanation suggests to me that it is expected that
execFileSynccannot be used with both a custom shell and arguments. is that correct, @bnoordhuis?On a related note, the described problem does not exist with
execFile. That discrepancy is unexpected to me.For reference, I tested this on
Ubuntu 20.04.4 LTSwith bothNode v16.15.0andNode v18.3.0using the script:bnoordhuis commentedon Jun 6, 2022
@ericcornelissen
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
argsafter normalization:Can you open a new issue for that?
ericcornelissen commentedon Jun 6, 2022
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
argsifoptions.shellis truthy:node/lib/child_process.js
Lines 564 to 565 in b631086
we pass the individual
argstospawn. So, oversimplified, do:Am I missing something or would that make sense?
Done 🙂
davewichers commentedon Nov 22, 2022
@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.
ericcornelissen commentedon Nov 22, 2022
@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.