Quotes not consumed
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 519
- Forks
- 129
- Avg merge
- 1h 34m
- Merged PRs (30d)
- 1
Description
Version: 13.1.0
See also #93 and #138 which both apparently conflict in their expectations of what should happen to quotes.
When I run parse('a "b c"') I expect the quotes to be consumed, as happens with most proper shells, but this is not what happens:
> parse('a "b c"')
{ _: [ 'a', '"b c"' ] }
This expectation appears to be different for different people and I'm not sure if this actually is a bug, but it's not at all what I expected it happen. Is it possible that we could get an option for how quotes are to be treated?
Here's what I expect to happen based on the behavior of sane shells:
a "b c"becomes['a', 'b c']a b\ cbecomes['a', 'b c']a '"b c"'becomes['a', '"b c"']a \"b c\"becomes['a', '"b', 'c"']
yargs-parser does something different in all cases. The last one in particular is most surprising.
> parse('a "b c"')
{ _: [ 'a', '"b c"' ] }
> parse('a b\\ c')
{ _: [ 'a', 'b\\', 'c' ] }
> parse('a \'"b c"\'')
{ _: [ 'a', '\'"b c"\'' ] }
> parse('a \\"b c\\"')
{ _: [ 'a', '\\"b c\\"' ] }
There doesn't seem to be any way to get a literal space into an argument without quotes. If yargs leaves the quotes in, then suddenly it's the responsibility of my application to understand that quotes might be present and strip them. This means my application is doing the work of the parser, and that feels very, very wrong -- otherwise, why am I using yargs?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the parse() entry point and reproduce the four quoted-argument examples from the issue. Read related issues #93 and #138 to understand the conflicting expectations before deciding what behavior or option is intended. Done means the chosen quote-handling behavior is consistent with the documented examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100