splitargs icon indicating copy to clipboard operation
splitargs copied to clipboard

quotes

Open stevenvachon opened this issue 10 years ago • 3 comments

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?

stevenvachon avatar Nov 14 '14 21:11 stevenvachon

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.

elgs avatar Nov 14 '14 21:11 elgs

Great! Thanks

stevenvachon avatar Nov 14 '14 22:11 stevenvachon

@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?

elgs avatar Feb 27 '15 07:02 elgs