Sha256: 987b4021423d32c676cbc3cd37498f7c23e039a124dbcd05f5a92e5021720d96
Contents?: true
Size: 1009 Bytes
Versions: 4
Compression:
Stored size: 1009 Bytes
Contents
exports.quote = function (xs) { return xs.map(function (s) { if (/["\s]/.test(s) && !/'/.test(s)) { return "'" + s.replace(/(['\\])/g, '\\$1') + "'"; } else if (/["'\s]/.test(s)) { return '"' + s.replace(/(["\\$`(){}!#&*|])/g, '\\$1') + '"'; } else { return s.replace(/([\\$`(){}!#&*|])/g, '\\$1'); } }).join(' '); }; exports.parse = function (s) { return s.match(/(['"])((\\\1|[^\1])*?)\1|(\\ |\S)+/g) .map(function (s) { if (/^'/.test(s)) { return s .replace(/^'|'$/g, '') .replace(/\\(["'\\$`(){}!#&*|])/g, '$1'); ; } else if (/^"/.test(s)) { return s .replace(/^"|"$/g, '') .replace(/\\(["'\\$`(){}!#&*|])/g, '$1'); ; } else return s.replace(/\\([ "'\\$`(){}!#&*|])/g, '$1'); }) ; };
Version data entries
4 entries across 4 versions & 2 rubygems