Convert ANSI-C quoted strings to their value

Open
#346 13 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript
Domain
cli

Research direction

Start at the yargs.parse entry point and compare its handling of the provided double-quoted, single-quoted, and ANSI-C quoted examples. Use the linked Bash ANSI-C Quoting reference to define the expected conversion, while preserving existing quoted-string behavior. Done means $'...' values are returned in their interpreted form rather than requiring callers to parse them.

Written by the indexing model from the issue text.

Description

feature

This makes sense:

> yargs.parse('echo --data "\\n"');
{ _: [ 'echo' ], data: '\\n', '$0': '' }
> yargs.parse("echo --data '\\n'");
{ _: [ 'echo' ], data: '\\n', '$0': '' }

This could be better:

> yargs.parse("echo --data $'\\n'");
{ _: [ 'echo' ], data: "$'\\n'", '$0': '' }

In bash, strings of the form $'string' are a special type of string:

$ echo $'some\\ntext'
some\ntext
$ echo 'some\\ntext'
some\\ntext

See https://www.gnu.org/software/bash/manual/bash.html#ANSI_002dC-Quoting

It would be helpful if yargs returned the raw value for these types of strings as well, instead of making the user parse it themselves.

Dominant language
JavaScript
Stars
519
Forks
129
Avg merge
1h 34m
Merged PRs (30d)
1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from yargs/yargs-parser

All issues in yargs/yargs-parser

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.