[Pkg-javascript-commits] [node-shell-quote] 25/137: denormalize the interpolate logic to make room for special cases
Bastien Roucariès
rouca at moszumanska.debian.org
Fri Aug 25 19:19:36 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-shell-quote.
commit c669d2e8b84e0eb0dde1798eae7c37a21dc5b7a1
Author: James Halliday <mail at substack.net>
Date: Sun Apr 14 20:40:23 2013 -0700
denormalize the interpolate logic to make room for special cases
---
index.js | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/index.js b/index.js
index f87d77f..3406d82 100644
--- a/index.js
+++ b/index.js
@@ -16,7 +16,7 @@ var re = {
chunk: /(['"])((\\\1|[^\1])*?)\1|(\\ |\S)+/g
};
-exports.parse = function (s, env) {
+exports.parse = function parse (s, env) {
if (!env) env = {};
return s.match(re.chunk).map(function (s) {
if (/^'/.test(s)) {
@@ -26,18 +26,20 @@ exports.parse = function (s, env) {
;
}
else if (/^"/.test(s)) {
- return interpolate(s.replace(/^"|"$/g, ''));
+ return s
+ .replace(/^"|"$/g, '')
+ .replace(/(^|[^\\])\$(\w+)/g, getVar)
+ .replace(/(^|[^\\])\${(\w+)}/g, getVar)
+ .replace(/\\([ "'\\$`(){}!#&*|])/g, '$1')
+ ;
}
- else return interpolate(s);
- });
-
- function interpolate (s) {
- return s
+ else return s
.replace(/(^|[^\\])\$(\w+)/g, getVar)
.replace(/(^|[^\\])\${(\w+)}/g, getVar)
.replace(/\\([ "'\\$`(){}!#&*|])/g, '$1')
;
- }
+ });
+
function getVar (_, pre, key) {
return pre + String(env[key] || '');
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-shell-quote.git
More information about the Pkg-javascript-commits
mailing list