Comparing version 0.0.2 to 0.1.0
@@ -29,3 +29,3 @@ // Generated by CoffeeScript 1.3.3 | ||
field = ""; | ||
scan(line, /\s*(?:([^\s\\\'\"]+)|'([^\']*)'|"((?:[^\"\\]|\\.)*)"|(\\.?)|(\S))(\s|$)?/, function(match) { | ||
scan(line, /\s*(?:([^\s\\\'\"]+)|'((?:[^\'\\]|\\.)*)'|"((?:[^\"\\]|\\.)*)"|(\\.?)|(\S))(\s|$)?/, function(match) { | ||
var dq, escape, garbage, raw, seperator, sq, word; | ||
@@ -48,2 +48,12 @@ raw = match[0], word = match[1], sq = match[2], dq = match[3], escape = match[4], garbage = match[5], seperator = match[6]; | ||
exports.escape = function(str) { | ||
if (str == null) { | ||
str = ""; | ||
} | ||
if (str == null) { | ||
return "''"; | ||
} | ||
return str.replace(/([^A-Za-z0-9_\-.,:\/@\n])/g, "\\$1").replace(/\n/g, "'\n'"); | ||
}; | ||
}).call(this); |
@@ -5,3 +5,3 @@ { | ||
"description": "Manipulate strings according to the word parsing rules of the UNIX Bourne shell.", | ||
"version": "0.0.2", | ||
"version": "0.1.0", | ||
"homepage": "https://github.com/jimmycuadra/shellwords", | ||
@@ -8,0 +8,0 @@ "repository": { |
# Shellwords | ||
Shellwords provides a function to manipulate strings according to the word parsing rules of the UNIX Bourne shell. | ||
Shellwords provides functions to manipulate strings according to the word parsing rules of the UNIX Bourne shell. It is based on [the Ruby module of the same name](http://www.ruby-doc.org/stdlib-1.9.3/libdoc/shellwords/rdoc/Shellwords.html). | ||
@@ -12,6 +12,9 @@ ## Installation | ||
``` javascript | ||
var split = require("shellwords").split; | ||
var shellwords = require("shellwords"); | ||
console.log(split("foo 'bar baz'")); | ||
shellwords.split("foo 'bar baz'"); | ||
// ["foo", "bar baz"] | ||
shellwords.escape("What's up, yo?"); | ||
// 'What\\\'s\\ up,\\ yo\\?' | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7942
53
20