shell-quote
Advanced tools
Comparing version 1.5.0 to 1.6.0
39
index.js
@@ -58,2 +58,3 @@ var json = typeof JSON !== undefined ? JSON : require('jsonify'); | ||
var match = filter(s.match(chunker), Boolean); | ||
var commented = false; | ||
@@ -63,3 +64,6 @@ if (!match) return []; | ||
if (!opts) opts = {}; | ||
return map(match, function (s) { | ||
return map(match, function (s, j) { | ||
if (commented) { | ||
return; | ||
} | ||
if (RegExp('^' + CONTROL + '$').test(s)) { | ||
@@ -85,3 +89,2 @@ return { op: s }; | ||
var quote = false; | ||
var varname = false; | ||
var esc = false; | ||
@@ -93,3 +96,3 @@ var out = ''; | ||
var c = s.charAt(i); | ||
isGlob = isGlob || (!quote && (c === '*' || c === '?')) | ||
isGlob = isGlob || (!quote && (c === '*' || c === '?')); | ||
if (esc) { | ||
@@ -120,3 +123,3 @@ out += c; | ||
else { | ||
out += c | ||
out += c; | ||
} | ||
@@ -126,3 +129,3 @@ } | ||
else if (c === DQ || c === SQ) { | ||
quote = c | ||
quote = c; | ||
} | ||
@@ -132,4 +135,11 @@ else if (RegExp('^' + CONTROL + '$').test(c)) { | ||
} | ||
else if (RegExp('^#$').test(c)) { | ||
commented = true; | ||
if (out.length){ | ||
return [out, { comment: s.slice(i+1) + match.slice(j+1).join(' ') }]; | ||
} | ||
return [{ comment: s.slice(i+1) + match.slice(j+1).join(' ') }]; | ||
} | ||
else if (c === BS) { | ||
esc = true | ||
esc = true; | ||
} | ||
@@ -144,3 +154,3 @@ else if (c === DS) { | ||
return out | ||
return out; | ||
@@ -152,3 +162,3 @@ function parseEnvVar() { | ||
if (s.charAt(i) === '{') { | ||
i += 1 | ||
i += 1; | ||
if (s.charAt(i) === '}') { | ||
@@ -174,3 +184,3 @@ throw new Error("Bad substitution: " + s.substr(i - 2, 3)); | ||
} else { | ||
varname = s.substr(i, varend.index) | ||
varname = s.substr(i, varend.index); | ||
i += varend.index - 1; | ||
@@ -181,3 +191,10 @@ } | ||
} | ||
}); | ||
}) | ||
// finalize parsed aruments | ||
.reduce(function(prev, arg){ | ||
if (arg === undefined){ | ||
return prev; | ||
} | ||
return prev.concat(arg); | ||
},[]); | ||
@@ -193,2 +210,2 @@ function getVar (_, pre, key) { | ||
} | ||
}; | ||
} |
{ | ||
"name": "shell-quote", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"description": "quote and parse shell commands", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
19332
16
394
143