CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
README.md169 linesDownload Raw Back to shell-quote
1# shell-quote <sup>[![Version Badge][npm-version-svg]][package-url]</sup>2 3[![github actions][actions-image]][actions-url]4[![coverage][codecov-image]][codecov-url]5[![License][license-image]][license-url]6[![Downloads][downloads-image]][downloads-url]7 8[![npm badge][npm-badge-png]][package-url]9 10Parse and quote shell commands.11 12# example13 14## quote15 16``` js17var quote = require('shell-quote/quote');18var s = quote([ 'a', 'b c d', '$f', '"g"' ]);19console.log(s);20```21 22output23 24```25a 'b c d' \$f '"g"'26```27 28## parse29 30``` js31var parse = require('shell-quote/parse');32var xs = parse('a "b c" \\$def \'it\\\'s great\'');33console.dir(xs);34```35 36output37 38```39[ 'a', 'b c', '\\$def', 'it\'s great' ]40```41 42## parse with an environment variable43 44``` js45var parse = require('shell-quote/parse');46var xs = parse('beep --boop="$PWD"', { PWD: '/home/robot' });47console.dir(xs);48```49 50output51 52```53[ 'beep', '--boop=/home/robot' ]54```55 56## parse with custom escape character57 58``` js59var parse = require('shell-quote/parse');60var xs = parse('beep ^--boop="$PWD"', { PWD: '/home/robot' }, { escape: '^' });61console.dir(xs);62```63 64output65 66```67[ 'beep --boop=/home/robot' ]68```69 70## parsing shell operators71 72``` js73var parse = require('shell-quote/parse');74var xs = parse('beep || boop > /byte');75console.dir(xs);76```77 78output:79 80```81[ 'beep', { op: '||' }, 'boop', { op: '>' }, '/byte' ]82```83 84## parsing shell comment85 86``` js87var parse = require('shell-quote/parse');88var xs = parse('beep > boop # > kaboom');89console.dir(xs);90```91 92output:93 94```95[ 'beep', { op: '>' }, 'boop', { comment: '> kaboom' } ]96```97 98# methods99 100``` js101var quote = require('shell-quote/quote');102var parse = require('shell-quote/parse');103```104 105## quote(args)106 107Return a quoted string for the array `args` suitable for using in shell108commands.109 110Each entry of `args` may be a string, or one of the object shapes that111`parse` emits: `{ op }` (where `op` is one of the control operators112`||`, `&&`, `;;`, `|&`, `<(`, `<<<`, `>>`, `>&`, `<&`, `&`, `;`, `(`,113`)`, `|`, `<`, `>`), `{ op: 'glob', pattern }`, or `{ comment }`. Any114other object shape, an unrecognized `op`, or a `pattern`/`comment`115containing line terminators throws a `TypeError`.116 117## parse(cmd, env={})118 119Return an array of arguments from the quoted string `cmd`.120 121Interpolate embedded bash-style `$VARNAME` and `${VARNAME}` variables with122the `env` object which like bash will replace undefined variables with `""`.123 124`env` is usually an object but it can also be a function to perform lookups.125When `env(key)` returns a string, its result will be output just like `env[key]`126would. When `env(key)` returns an object, it will be inserted into the result127array like the operator objects.128 129When a bash operator is encountered, the element in the array with be an object130with an `"op"` key set to the operator string. For example:131 132```133'beep || boop > /byte'134```135 136parses as:137 138```139[ 'beep', { op: '||' }, 'boop', { op: '>' }, '/byte' ]140```141 142# install143 144With [npm](http://npmjs.org) do:145 146```147npm install shell-quote148```149 150# license151 152MIT153 154[package-url]: https://npmjs.org/package/shell-quote155[npm-version-svg]: https://versionbadg.es/ljharb/shell-quote.svg156[deps-svg]: https://david-dm.org/ljharb/shell-quote.svg157[deps-url]: https://david-dm.org/ljharb/shell-quote158[dev-deps-svg]: https://david-dm.org/ljharb/shell-quote/dev-status.svg159[dev-deps-url]: https://david-dm.org/ljharb/shell-quote#info=devDependencies160[npm-badge-png]: https://nodei.co/npm/shell-quote.png?downloads=true&stars=true161[license-image]: https://img.shields.io/npm/l/shell-quote.svg162[license-url]: LICENSE163[downloads-image]: https://img.shields.io/npm/dm/shell-quote.svg164[downloads-url]: https://npm-stat.com/charts.html?package=shell-quote165[codecov-image]: https://codecov.io/gh/ljharb/shell-quote/branch/main/graphs/badge.svg166[codecov-url]: https://app.codecov.io/gh/ljharb/shell-quote/167[actions-image]: https://img.shields.io/github/check-runs/ljharb/shell-quote/main168[actions-url]: https://github.com/ljharb/shell-quote/actions169 
basant307/AI_Governance_Project · CoolFace