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

child_process exec '<()' unexpected token #11729

Closed
danielstaleiny opened this issue Mar 7, 2017 · 3 comments
Closed

child_process exec '<()' unexpected token #11729

danielstaleiny opened this issue Mar 7, 2017 · 3 comments
Labels
child_process Issues and PRs related to the child_process subsystem. question Issues that look for answers.

Comments

@danielstaleiny
Copy link

danielstaleiny commented Mar 7, 2017

  • Version: v7.7.1
  • Platform: Linux ai 4.9.11-1-ARCH x86_64 GNU/Linux
  • Subsystem: child_process

core module child_process.exec issue with <() command.

I executed same command in my bash and zsh shell everything works fine. Once I copy same command to code I get this error.
Shell command:
comm -13 <(sort new.csv | uniq) <(sort old.csv | uniq) > diff.csv
When executing same shell command it trows me error:

/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `comm -13 <(sort new.csv | uniq) <(sort old.csv | uniq) > diff.csv'

Code:

  exec(`comm -13 <(sort new.csv | uniq) <(sort old.csv | uniq) > diff.csv`,
                (error, stdout, stderr) => {
                    if (error) {
                          return error
                    }
                    console.log(`${stdout}`)
                    console.log(`${stderr}`)
                })

After troubleshooting I think problem is with <( part of the command.

@addaleax addaleax added child_process Issues and PRs related to the child_process subsystem. question Issues that look for answers. labels Mar 7, 2017
@addaleax
Copy link
Member

addaleax commented Mar 7, 2017

Try passing the shell option to child_process.exec, e.g. { "shell": "/bin/bash" }, when you’re using shell-specific syntax like this

@danielstaleiny
Copy link
Author

Works. Thank you very much.

@rahul799
Copy link

rahul799 commented Oct 17, 2020

Hey,
I am facing the same issue.

exec('jsdoc -X ./src/!(selector)/*.js > ./documentation/jsdocAST.json', { "shell": "/bin/bash" },(err, stdout, stderr) => {
  if (err) {
    //some err occurred
    console.error(err)
  } else {
   // the *entire* stdout and stderr (buffered)
   console.log(`stdout: ${stdout}`);
   console.log(`stderr: ${stderr}`);
  }
});

isn't it correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
child_process Issues and PRs related to the child_process subsystem. question Issues that look for answers.
Projects
None yet
Development

No branches or pull requests

4 participants