Created
May 28, 2012 23:06
-
-
Save polotek/2821573 to your computer and use it in GitHub Desktop.
Testing @substack's shell-quote lib for parsing cli arg strings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var s = require('shell-quote'); | |
console.log(s.parse('"foo = \"foo\""')); // [ 'foo', '=', 'foo' ] | |
// this is what I want | |
console.log(s.parse('"foo = \\"foo\\""')); // [ 'foo = "foo"' ] | |
// why does this also work? shouldn't it have slashes in it? | |
console.log(s.parse('"foo = \\\"foo\\\""')); // [ 'foo = "foo"' ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Javascript quotes are getting in the way with the last example. It works fine if you read the string from a text file instead:
s.txt:
output: