1. any-shell-escape
Escape and stringify an array of arguments to be executed on the shell
any-shell-escape
Package: any-shell-escape
Created by: boazy
Last modified: Thu, 03 Aug 2023 02:19:23 GMT
Version: 0.1.1
License: MIT
Downloads: 358,594
Repository: https://github.com/boazy/any-shell-escape

Install

npm install any-shell-escape
yarn add any-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

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code