Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process.parse_arguments escapes quotes when it should not #10306

Closed
erdnaxeli opened this issue Jan 27, 2021 · 0 comments · Fixed by #10337
Closed

Process.parse_arguments escapes quotes when it should not #10306

erdnaxeli opened this issue Jan 27, 2021 · 0 comments · Fixed by #10337
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:system

Comments

@erdnaxeli
Copy link
Contributor

erdnaxeli commented Jan 27, 2021

Hi,

I once wrote a lib to do exactly the same thing as the new Process.parse_arguments, so I tried to run my tests with the new stdlib method. And this one does not work:

require "process"

pp ARGV
pp Process.parse_arguments(%(this 'is a "'very wei"rd co"m"mand please" don't do t'h'a't p"leas"e))
$ crystal y.cr -- this 'is a "'very wei"rd co"m"mand please" don't do t'h'a't p"leas"e
["--", "this", "is a \"very", "weird command please", "dont do that", "please"]
["this",
 "is a \"very",
 "wei\"rd",
 "co\"m\"mand",
 "please\"",
 "don't",
 "do",
 "t'h'a't",
 "p\"leas\"e"]

The thing is 'something "quote' keeps the quote, because it is enclosed in single quotes, but something"else"quote is just a string concatenated to another string concatenated to another one. The stdlib method keeps all quotes whether they are quoted or not, which is incorrect.

The split of the string is also incorrect. Specifically something"else with spaces"quote are 3 strings concatenated, and it should not be splitted on spaces as their are quoted. It seems also that some quotes are ignored (like in don't)?

I will try to propose a PR.

@erdnaxeli erdnaxeli changed the title Process.parse_arguments escape quotes when it should not Process.parse_arguments escapes quotes when it should not Jan 27, 2021
@straight-shoota straight-shoota added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:system labels Jan 27, 2021
makenowjust added a commit to makenowjust/crystal that referenced this issue Jan 30, 2021
bcardiff pushed a commit that referenced this issue Feb 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants