Skip to content
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

spawn method use <<< redirection unexpected #2700

Closed
zhangwinning opened this issue May 14, 2020 · 2 comments
Closed

spawn method use <<< redirection unexpected #2700

zhangwinning opened this issue May 14, 2020 · 2 comments

Comments

@zhangwinning
Copy link

What steps will reproduce the bug?

test.js

#!/usr/bin/env node
let spawn = require("child_process").spawn;
function showContent(content) {
  spawn(`cat <<< "${content}" | less -r`, {
    stdio: "inherit", // use the current shell for stdio
    shell: true,
  });
}
showContent("hello");

-rwxr-xr-x  test.js

the function is executable. so ./test.js is ok. while error is produce. error is the following

/bin/sh: 1: Syntax error: redirection unexpected

How often does it reproduce? Is there a required condition?

on my mac OS, it is ok, while in the linux, the error will trigger.

What is the expected behavior?

perform normal

What do you see instead?

Additional information

I dig into the <<< redirection,The default system shell in Ubuntu is dash, not bash. Dash does not have the <<< redirection operator. that could be the problem. while I don't know how to solve it.
stackoverflow

@bnoordhuis bnoordhuis transferred this issue from nodejs/node May 14, 2020
@bnoordhuis
Copy link
Member

Wrong repo, moved.

Try passing { shell: '/bin/bash' }.

@zhangwinning
Copy link
Author

@bnoordhuis thanks , passing { shell: '/bin/bash' } it's ok, I close this issue at once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants