any-shell-escape
Escape and stringify an array of arguments to be executed on the shell
Last updated 11 years ago by boazy .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install any-shell-escape 
SYNC missed versions from official npm registry.

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

Current Tags

  • 0.1.1                                ...           latest (11 years ago)

2 Versions

  • 0.1.1                                ...           11 years ago
  • 0.1.0                                ...           11 years ago
Maintainers (1)
Downloads
Total 2
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE