-
-
Notifications
You must be signed in to change notification settings - Fork 34.9k
Open
Labels
cliIssues and PRs related to the Node.js command line interface.Issues and PRs related to the Node.js command line interface.confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.
Description
Version
v17.9.0
Platform
Darwin [redacted] 19.6.0 Darwin Kernel Version 19.6.0: Tue Feb 15 21:39:11 PST 2022; root:xnu-6153.141.59~1/RELEASE_X86_64 x86_64
Subsystem
No response
What steps will reproduce the bug?
Execute the following:
$ node -pe "-0"And you will get back:
node: --eval requires an argument
In fact, anything where the - comes first, you get this message.
For example, all of the following also result in the above message:
$ node -pe "-42"
$ node -pe "-"
$ node -pe "-NaN"How often does it reproduce? Is there a required condition?
It's always reproducable (at least on this version and machine).
What is the expected behavior?
I'd like it to not spit back an error message and give me the evaluated value, please.
What do you see instead?
An error message detailing that the "eval" option was not given a value.
Additional information
It seems that the CLI is not properly parsing its arguments?
Prefixing the expression with 0 seems to work:
$ node -pe "0-42"
42As well as using a comma operator:
$ node -pe "(0, -42)"
-42Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
cliIssues and PRs related to the Node.js command line interface.Issues and PRs related to the Node.js command line interface.confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.