[go: nahoru, domu]

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

Protect argv._ / non-hyphenated options array #878

Open
inukshuk opened this issue May 21, 2017 · 2 comments
Open

Protect argv._ / non-hyphenated options array #878

inukshuk opened this issue May 21, 2017 · 2 comments

Comments

@inukshuk
Copy link

I ran into a bizarre error on macOS where an app would not start the first time after confirming the gatekeeper message; the app would halt unexpectedly (on subsequent starts, everything was fine). The reason, it turns out, was that gatekeeper seems to start the app with an extra command line parameter including underscores (e.g., -ps_0_12345). yargs interprets those underscores as boolean parameters and, when storing them, overwrites the non-hyphenated options array.

$ cat args.js 
#!/usr/bin/env node
console.dir(require('yargs').argv)

$ ./args.js
{ _: [], '$0': 'args.js' }
$ ./args.js -_
{ _: [ true ], '$0': 'args.js' }
@bcoe
Copy link
Member
bcoe commented May 21, 2017

@inukshuk seems like a reasonable safety to not allow a user to set an argument named _ -- we'll need to make this change in a major version.

@nexdrew do you agree?

@DeeDeeG
Copy link
DeeDeeG commented Jan 13, 2021

I personally support the argv._ array being totally protected, or making it an opt-in configuration to allow -_/--_ underscore flags.

Or more generally, having it not be possible for hyphenated arguments to end up in with the non-hyphenated arguments array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants