You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue is still there, it's with the argv / pre-split mode. If you put your code into a file and pass the args in (.argv instead of .parse()) you'll see it even with [email protected].
Alternatively, this parse call reproduces the same incorrect result: .parse(['cmd', '"Hello"', '"World"', '--opt1', '":)"']);
Additionally, note that ""..."" is not a double quoting in shell, in fact the body will be unquoted and each pair of two quotes represent empty strings. So that's three sequential string literals that get concatenated. This is why I had to do '"..."' in my above repro.
If you run .parse('cmd ""Hello World"" --opt1 "":) haha""') you'll see how yargs doesn't actually obey that quoting style:
This splitting is faithful to the shell interpretation of those quotes, however to fully reflect a shell, the empty double quotes should've been dropped. I suspect that the quote dropping is being done at the wrong part of the parse pipeline.
Activity
[-]Positional arguments eats quotes[/-][+]Positional arguments eat quotes[/+]jedwards1211 commentedon Mar 9, 2021
Not just positional arguments, options eat quotes too. Is some kind of JSON parsing going on? Should have been documented from the get-go
jly36963 commentedon Jul 20, 2021
I'm using yargs@17, and this is what I observed:
logs:
I wrapped each of the positionals/options with extra quotes, and they were preserved.
I don't think this problem exists anymore. At some point they must have resolved the issue.
danopia commentedon Jul 20, 2021
The issue is still there, it's with the
argv/ pre-split mode. If you put your code into a file and pass the args in (.argvinstead of.parse()) you'll see it even with[email protected].Alternatively, this parse call reproduces the same incorrect result:
.parse(['cmd', '"Hello"', '"World"', '--opt1', '":)"']);Additionally, note that
""...""is not a double quoting in shell, in fact the body will be unquoted and each pair of two quotes represent empty strings. So that's three sequential string literals that get concatenated. This is why I had to do'"..."'in my above repro.If you run
.parse('cmd ""Hello World"" --opt1 "":) haha""')you'll see how yargs doesn't actually obey that quoting style:This splitting is faithful to the shell interpretation of those quotes, however to fully reflect a shell, the empty double quotes should've been dropped. I suspect that the quote dropping is being done at the wrong part of the parse pipeline.