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

--check flag doesn't always prevent execution #11680

Closed
atg opened this issue Mar 3, 2017 · 1 comment
Closed

--check flag doesn't always prevent execution #11680

atg opened this issue Mar 3, 2017 · 1 comment
Labels
cli Issues and PRs related to the Node.js command line interface. confirmed-bug Issues with confirmed bugs.

Comments

@atg
Copy link

atg commented Mar 3, 2017

  • Version: all
  • Platform: all
  • Subsystem: internal/bootstrap_node.js
-c, --check
       Syntax check the script without executing.

The node --check flag is supposed to check syntax and then stop. However, as currently implemented the --check flag is ignored if the script to be checked is given via stdin or via -e flag; and the script is executed regardless.

For instance:

$ echo 'console.log("hello")' | node --check

$ node --check -e 'console.log("hello")'
  • Expected behaviour: nothing prints (but any syntax errors are reported)
  • Actual behaviour: "hello" is printed to stdout in both cases
@atg atg changed the title --check flag doesn't always prevent execution --check flag doesn't always prevent execution Mar 3, 2017
@mscdex mscdex added the cli Issues and PRs related to the Node.js command line interface. label Mar 3, 2017
@not-an-aardvark not-an-aardvark added the confirmed-bug Issues with confirmed bugs. label Mar 5, 2017
not-an-aardvark added a commit to not-an-aardvark/node that referenced this issue Apr 1, 2017
Previously, the --check CLI flag had no effect when run on code piped
from stdin. This commit updates the bootstrap logic to handle the
--check flag the same way regardless of whether the code is piped from
stdin.

Fixes: nodejs#11680
not-an-aardvark added a commit to not-an-aardvark/node that referenced this issue Apr 4, 2017
The -c flag ("check script syntax") and -e flag ("evaluate given code")
have contradictory meanings. Make them mutually exclusive by throwing
when both of them are provided.

Fixes: nodejs#11680
PR-URL: nodejs#11689
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
@jdalton
Copy link
Member

jdalton commented Jan 29, 2018

node --check -e 'console.log("hello")'

👆 Due to not-an-aardvark@a5f91ab this exits with the message:

node: either --check or --eval can be used, not both

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Issues and PRs related to the Node.js command line interface. confirmed-bug Issues with confirmed bugs.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants