From f53598732ba606c7bca66fd7d55d809544c452cf Mon Sep 17 00:00:00 2001 From: James Halliday Date: Mon, 13 May 2013 03:06:38 -0700 Subject: [PATCH] using the control ops directly from the docs --- index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 22cbf14..66d9185 100644 --- a/index.js +++ b/index.js @@ -12,14 +12,16 @@ exports.quote = function (xs) { }).join(' '); }; -var CONTROL = '(?:\\|\\||\\&\\&|;;|\\|\\&[&;()|])'; +var CONTROL = '(?:' + [ + '\\|\\|', '\\&\\&', ';;', '\\|\\&', '[&;()|]' +].join('|') + ')'; var META = '[|&;()<> \\t]'; exports.parse = function parse (s, env) { var chunker = new RegExp([ '([\'"])((\\\\\\1|[^\\1])*?)\\1', // quotes '(\\\\' + META + '|[^\\s&|])+', // barewords - '([&|])' // control chars + '(' + CONTROL + ')' // control chars ].join('|'), 'g'); var match = s.match(chunker); if (!match) return [];