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

Deprecate execa.shell() in favor of execa(..., { shell: true }) #211

Closed
ehmicky opened this issue May 2, 2019 · 3 comments · Fixed by #219
Closed

Deprecate execa.shell() in favor of execa(..., { shell: true }) #211

ehmicky opened this issue May 2, 2019 · 3 comments · Fixed by #219
Assignees

Comments

@ehmicky
Copy link
Collaborator

ehmicky commented May 2, 2019

Should we deprecate and/or remove execa.shell() in favor of execa(..., { shell: true })?

The reason being shell is a misused option, which creates problems, so we should not encourage its use by providing a shortcut method.

Some of the issues with the shell option:

  1. It is not cross-platform. While it does call cmd.exe on Windows and /bin/sh on Unix, those shells have different syntaxes. If the command uses shell-specific syntax, it won't be cross-platform. It it does not, shell is not needed.
  2. It is slower, as it interprets the command through a shell interpreter.
  3. It is unsafe as it allows for command injection.
  4. It is often used only to be able to pass command and arguments as a string string. Which is not an issue anymore since Support single string input without using the shell option #182

There are some legitimate use cases for the shell option, but I believe 99% of the times its usage does not satisfy the following criteria:
a) shell is only useful for shell-specific features not available in JavaScript and Node.js. There are really not many of those.
b) shell is only useful when cross-platform is not a concern.

Note: I can submit a PR if approved.

@marcotuna

This comment has been minimized.

@sindresorhus
Copy link
Owner

👍 Also include your above points in the shell option docs and TS type for it.

@ehmicky
Copy link
Collaborator Author

ehmicky commented May 7, 2019

Done in #219

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

Successfully merging a pull request may close this issue.

3 participants