Skip to content

Trailing and leading quote characters are removed #201

Closed

Description

@mefcorvi

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.

Activity

  1. changed the title [-]Question about quoting again[/-] [+]Trailing and leading quote characters are removed[/+] on Sep 1, 2019
  2. bcoe commented on Sep 6, 2019

    @bcoe
    Member

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

  3. juergba commented on Oct 31, 2019

    @juergba
    Contributor

    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.

  4. shadowspawn commented on Mar 12, 2023

    @shadowspawn
    Member

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions