镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Node doesn't pass -v to eval'd script #21674

Closed

Description

@steven10172
  • Version: v8.9.4
  • Platform: 64-bit Mac (Darwin Kernel Version 15.6.0) && Linux 3.2.45-0.6.wd.865.49.315.metal1.x86_64
  • Subsystem:

Current Behavior:
When eval'ing an inline script (node -e) you can freely pass arguments, but if it's a flag that node understands it will evaluate that flag instead of running the inlined script.

Expected Behavior:
I would expect this behavior to match the behavior of running a non-eval'd script.

Example (inline):

$ node -e "console.log(process.argv)" "test"
[ '/Users/.../.nvm/versions/node/v8.9.4/bin/node', 'test' ]
$ node -e "console.log(process.argv)" -v
v8.9.4

Example (non-inline):

$ node test.js "test"
[ '/Users/.../.nvm/versions/node/v8.9.4/bin/node',
 '/.../test.js',
 'test' ]
$ node test.js -v
[ '/Users/.../.nvm/versions/node/v8.9.4/bin/node',
 '/.../test.js',
 '-v' ]

Activity

  1. added
    cliIssues and PRs related to the Node.js command-line interface.
    on Jul 5, 2018
  2. steven10172 commented on Jul 5, 2018

    @steven10172
    Author

    Closing as this can be achieved by using --

    Example:

    $ node -e "console.log(process.argv)" -- "test"
    [ '/Users/.../.nvm/versions/node/v8.9.4/bin/node', 'test' ]
    $ node -e "console.log(process.argv)" -- -v
    v8.9.4
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    cliIssues and PRs related to the Node.js command-line interface.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions