splitargs
splitargs copied to clipboard
quotes
On OSX, the following command line:
npm config set init.author.name Steven"Vachon" --verbose
produces the following value for process.argv
:
["npm","config","set","init.author.name","Steven\"Vachon\"","--verbose"]
while splitargs produces:
["npm","config","set","init.author.name","StevenVachon","--verbose"]
What are your thoughts on how quotes should be handled?
It seems splitargs
completely stripped the quotes off. I wrote some test code:
var splitargs = require('splitargs');
var i1 = "npm config set init.author.name Steven\"Vachon\" --verbose";
var o1 = splitargs(i1);
console.log(o1);
which yields the following output:
[ 'npm',
'config',
'set',
'init.author.name',
'StevenVachon',
'--verbose' ]
@stevenvachon thanks for finding this issue. I will go ahead and improve it.
Great! Thanks
@stevenvachon sorry for a long time idling, shame on me. After some consideration on this question, I think if you want to get:
["npm","config","set","init.author.name","Steven\"Vachon\"","--verbose"]
You probably need to have:
npm config set init.author.name 'Steven"Vachon"' --verbose
as input.
The reason behind this is that the primary purpose of the quotes (single or double) is to retain several space separated tokens as a single one. If quotes themselves are part of the token itself, they should be wrapped inside an enclosing quotes. Your ideas?