shell-escape

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

shell-escape downloads shell-escape version shell-escape license

shell-escape

Npm Package Weekly Downloads Trend

3 Years
🌟 Show real-time usage chart on shell-escape's README.md, just copy the code below.
## Usage Trend
[![Usage Trend of shell-escape](https://npm-compare.com/img/npm-trend/THREE_YEARS/shell-escape.png)](https://npm-compare.com/shell-escape#timeRange=THREE_YEARS)

Cumulative GitHub Star Trend

🌟 Show GitHub stars trend chart on shell-escape's README.md, just copy the code below.
## GitHub Stars Trend
[![GitHub Stars Trend of shell-escape](https://npm-compare.com/img/github-trend/shell-escape.png)](https://npm-compare.com/shell-escape)

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
shell-escape758,28669-212 years agoMIT

README for shell-escape

shell-escape

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

Install

npm install shell-escape

Example

simple

var shellescape = require('shell-escape');

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('shell-escape');

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