Skip to content

Commit

Permalink
first part of op parsing works
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed May 13, 2013
1 parent d817736 commit e6f9199
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exports.quote = function (xs) {
};

exports.parse = function parse (s, env) {
var chunker = /(['"])((\\\1|[^\1])*?)\1|(\\ |\S)+/g;
var chunker = /(['"])((\\\1|[^\1])*?)\1|(\\ |\S)+|([&|])/g;
var match = s.match(chunker);
if (!match) return [];
if (!env) env = {};
Expand All @@ -32,6 +32,9 @@ exports.parse = function parse (s, env) {
.replace(/\\([ "'\\$`(){}!#&*|])/g, '$1')
;
}
else if (/^[&|]$/.test(s)) {
return { op: s };
}
else return s.replace(
/(['"])((\\\1|[^\1])*?)\1|[^'"]+/g,
function (s, q) {
Expand Down

0 comments on commit e6f9199

Please sign in to comment.