Skip to content

Instantly share code, notes, and snippets.

@robozevel
Created August 17, 2015 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robozevel/1e45c133c16f4f75f12f to your computer and use it in GitHub Desktop.
Save robozevel/1e45c133c16f4f75f12f to your computer and use it in GitHub Desktop.
var exec = require('child_process').exec;
var rForbidden = /(["'#&;`\|\*\?~<>\^\(\)\[\]\{\}\$\\\x0A\xFF])/g;
var isWindows = process.platform === 'win32';
module.exports = function(cmd, options, callback) {
cmd = cmd.replace(rForbidden, isWindows ? '^$1': '\\$1');
return exec(cmd, options, callback);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment