[Pkg-javascript-commits] [node-shell-quote] 80/137: factored out single and double quote regex

Bastien Roucariès rouca at moszumanska.debian.org
Fri Aug 25 19:19:41 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 de9e0a5081156e5483b5df24878c7414f90ec67e
Author: James Halliday <mail at substack.net>
Date:   Mon Jun 24 04:41:37 2013 -0700

    factored out single and double quote regex
---
 index.js | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/index.js b/index.js
index e1283a0..3119daa 100644
--- a/index.js
+++ b/index.js
@@ -19,6 +19,9 @@ var CONTROL = '(?:' + [
     '\\|\\|', '\\&\\&', ';;', '\\|\\&', '[&;()|<>]'
 ].join('|') + ')';
 var META = '|&;()<> \\t';
+var BAREWORD = '(\\\\[' + META + ']|[^\\s' + META + '])+';
+var SINGLE_QUOTE = '[^\\s\'"]*(")((\\\\"|[^"])*?)"[^\\s\'"]*';
+var DOUBLE_QUOTE = '[^\\s\'"]*(\')((\\\\\'|[^\'])*?)\'[^\\s\'"]*';
 
 var TOKEN = '';
 for (var i = 0; i < 4; i++) {
@@ -43,9 +46,9 @@ exports.parse = function (s, env) {
 
 function parse (s, env) {
     var chunker = new RegExp([
-        '[^\\s\'"]*(")((\\\\"|[^"])*?)"[^\\s\'"]*', // double quotes
-        '[^\\s\'"]*(\')((\\\\\'|[^\'])*?)\'[^\\s\'"]*', // single quotes
-        '(\\\\[' + META + ']|[^\\s' + META + '])+', // barewords
+        SINGLE_QUOTE,
+        DOUBLE_QUOTE,
+        BAREWORD,
         '(' + CONTROL + ')' // control chars
     ].join('|'), 'g');
     var match = s.match(chunker);

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