question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow multiple string arguments for exec()

See original GitHub issue

I’ve found that I end up doing a lot of messy string concatenation with exec() commands. It would be nice to allow multiple string arguments that would be joined together with a space, such as:

exec('npm', 'run-script', 'test');   // run "npm run-script test"

This could easily be backwards compatible with the current function since only the first argument is currently a string.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Reactions:2
  • Comments:18 (12 by maintainers)

github_iconTop GitHub Comments

6reactions
nfischercommented, Feb 3, 2016

@nzakas would this syntax work for you?

exec(['npm', 'run-script', 'test'].join(' '));   // run "npm run-script test"

The concern is that this makes parsing slightly harder, since exec() can take options as well as a callback.

1reaction
nfischercommented, Jul 1, 2016

We’re still working on an implementation in shelljs itself, but I implemented a shelljs extension for node v6+ that addresses some of the security concerns here, while also giving a very convenient syntax: https://github.com/nfischer/shelljs-exec-proxy

Read more comments on GitHub >

github_iconTop Results From Across the Web

Passing Arguments Using the EXEC Command - IBM
When you invoke a REXX exec either implicitly or explicitly using the EXEC command, you can pass either one or no arguments to...
Read more >
How to pass in multiple arguments to execute with .sh script
Show activity on this post. In this example, xargs will execute ./script.sh multiple times with a single argument read from its standard input. ......
Read more >
Passing variable as argument for exec.Command()
The following code returns a line with the delimiter (I work on Windows and its EOL is '\r\n'), something that wasn't shown when...
Read more >
Adding arguments and options to your Bash scripts - Red Hat
Another is the use of options and option arguments. This article explores these two methods for getting data into the script and controlling ......
Read more >
Exec execute commands with two parameters? - Scripts & Rules
In general - yep, you have the right approach. You can only pass one param to exec binding, so must combine everything into...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found