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

Trailing and leading quote characters are removed #201

Closed
mefcorvi opened this issue Sep 1, 2019 · 3 comments
Closed

Trailing and leading quote characters are removed #201

mefcorvi opened this issue Sep 1, 2019 · 3 comments

Comments

@mefcorvi
Copy link

mefcorvi commented Sep 1, 2019

Version 13.1.1

Description

Trailing and leading quote characters are removed from the values. If I want to pass a 'string' as a value I need to triple-quote it as "''string''" or \'''string\''' when I'm specifying that in the shell.

Expected

> require('yargs-parser')([ '--arg', '"option"' ])
{ _: [], arg: '"option"' }

Actual

> require('yargs-parser')([ '--arg', '"option"' ])
{ _: [], arg: 'option' }

This probably relates to #138, #180. Definitely relates to #145 and #153.
I would suggest introducing a new keepQuotes/trimQuotes option to support the all edge cases.

@mefcorvi mefcorvi changed the title Question about quoting again Trailing and leading quote characters are removed Sep 1, 2019
@bcoe
Copy link
Member

bcoe commented Sep 6, 2019

@mefcorvi in an ideal world my-app --argument \"foo\" would work, might be worth rethinking this bit of the parser.

@juergba
Copy link
Contributor

juergba commented Oct 31, 2019

We should distinguish between parsing a string or array.

  • array: require('yargs-parser')([ '--arg', '"option"' ]):
    we should not remove any double quotes => { _: [], arg: '"option"' }
  • string: require('yargs-parser')( '--arg "option"' ):
    to be discussed, IMO double quotes should be removed unless:
    • '--arg \"option\"' ?
    • """--arg "option"""" // raw string as in Kotlin ?
    • new configuration option ?

So the change would have to be done in "tokenize-arg-string.js", and not in our parser.

@shadowspawn
Copy link
Member

shadowspawn commented Mar 12, 2023

Thanks for the report, and the simple reproduction.

I can no longer reproduce the reported issue. I suspect it was fixed by #407.

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

Successfully merging a pull request may close this issue.

4 participants