microsoft / microsoft/knack

Issue parsing arguments with escaped text

Open
#165 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
358
Forks
101
PR merge metrics
No merged PRs in 30d

Description

While working on an azure CLI application I noticed some problems parsing (escaped) json and I've traced the problem back to Knack.

In short, with a nonspecific program based on Knack. The following launch params

python .\testknack.py -b '\"a long string\"' --debug

Results in:

Command arguments: ['-b', '{"a', 'long', 'string"}', '--debug']

As you can see, each word in the second argument gets parsed as a separate argument. This doesn't seem right, does it?

I'm using powershell on windows 10 by the way.

Cheers,
Jurgyy

Contributor guide

Open the contributing guide

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.

Research direction

Reproduce the reported command in a Windows PowerShell environment and compare the received argument list with the expected single JSON argument. Trace the repository's command-line argument parsing path and add coverage for escaped text containing spaces; done means the quoted JSON remains one argument while the surrounding options still parse correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.