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
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.
The text was updated successfully, but these errors were encountered:
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
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:The thing is
'something "quote'
keeps the quote, because it is enclosed in single quotes, butsomething"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 indon't
)?I will try to propose a PR.
The text was updated successfully, but these errors were encountered: