escape-it

0.3.0 • Public • Published

escape-it

Escape and stringify an array of arguments to be executed on the shell

Install

npm install escape-it

Example

simple

var shellescape = require('escape-it');
 
var args = ['curl', '-v', '-H', 'Location;', '-H', 'User-Agent: dave#10', 'http://www.daveeddy.com/?name=dave&age=24'];
 
var escaped = shellescape(args);
console.log(escaped);

yields

curl -v -H 'Location;' -H 'User-Agent: dave#10' 'http://www.daveeddy.com/?name=dave&age=24'

A command suitable for being executed by the shell

advanced

var shellescape = require('escape-it');
 
var args = ['echo', 'hello!', 'how are you doing $USER', '"double"', "'single'"];
 
var escaped = shellescape(args);
console.log(escaped);

yields

echo 'hello!' 'how are you doing $USER' '"double"' \''single'\'

and when run on the shell

$ echo 'hello!' 'how are you doing $USER' '"double"' \''single'\'
hello! how are you doing $USER "double" 'single'

License

MIT

Package Sidebar

Install

npm i escape-it

Weekly Downloads

221

Version

0.3.0

License

MIT

Unpacked Size

4.61 kB

Total Files

6

Last publish

Collaborators

  • mkg20001