{"name":"shell-quote","version":"1.8.3","keywords":["command","parse","quote","shell"],"author":{"url":"http://substack.net","name":"James Halliday","email":"mail@substack.net"},"license":"MIT","_id":"shell-quote@1.8.3","maintainers":[{"name":"goto-bus-stop","email":"npm@asdf.kooi.me"},{"name":"karissa","email":"krmckelv@gmail.com"},{"name":"ljharb","email":"ljharb@gmail.com"},{"name":"jiwaddell","email":"jacob.im.waddell@gmail.com"}],"homepage":"https://github.com/ljharb/shell-quote","bugs":{"url":"https://github.com/ljharb/shell-quote/issues"},"dist":{"shasum":"55e40ef33cf5c689902353a3d8cd1a6725f08b4b","tarball":"http://registry-npm.ywwl.com/shell-quote/download/shell-quote-1.8.3.tgz","fileCount":18,"integrity":"sha512-ObmnIF4hXNg1BqhnHmgbDETF8dLPCggZWBjkQfhZpbszZnYur5DUljTcCHii5LC3J5E0yeO/1LIMyH+UvHQgyw==","signatures":[{"sig":"MEUCIQClHFGvCxl0n+k8OsfO88hHyoO4w/p20GIAv/FgmgXwPAIgWUqVG8OHgpI6Stzp7dAcfoaqySGgFjJh3sacPULPtV8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":23744,"size":8334,"noattachment":false,"key":"/shell-quote/-/shell-quote-1.8.3.tgz"},"main":"index.js","engines":{"node":">= 0.4"},"funding":{"url":"https://github.com/sponsors/ljharb"},"gitHead":"487a9b41a7b6154d2a9c10bdffe65cf74d2c3ded","scripts":{"lint":"eslint --ext=js,mjs .","test":"npm run tests-only","prelint":"evalmd README.md","prepack":"npmignore --auto --commentLines=autogenerated","pretest":"npm run lint","version":"auto-changelog && git add CHANGELOG.md","posttest":"npx npm@'>=10.2' audit --production","prepublish":"not-in-publish || npm run prepublishOnly","tests-only":"nyc tape 'test/**/*.js'","postversion":"auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"","prepublishOnly":"safe-publish-latest"},"_npmUser":{"name":"ljharb","email":"ljharb@gmail.com"},"repository":{"url":"git+ssh://git@github.com/ljharb/shell-quote.git","type":"git"},"_npmVersion":"11.3.0","description":"quote and parse shell commands","directories":{},"_nodeVersion":"24.1.0","publishConfig":{"ignore":[".github/workflows","example","CHANGELOG.md"]},"_hasShrinkwrap":false,"auto-changelog":{"output":"CHANGELOG.md","template":"keepachangelog","hideCredit":true,"unreleased":false,"commitLimit":false,"backfillLimit":false,"startingVersion":"1.7.4"},"devDependencies":{"nyc":"^10.3.2","tape":"^5.9.0","eslint":"=8.8.0","evalmd":"^0.0.19","encoding":"^0.1.13","jackspeak":"=2.1.1","npmignore":"^0.3.1","in-publish":"^2.0.1","auto-changelog":"^2.5.0","safe-publish-latest":"^2.0.0","@ljharb/eslint-config":"^21.1.1"},"_npmOperationalInternal":{"tmp":"tmp/shell-quote_1.8.3_1748840585688_0.8379361015771527","host":"s3://npm-registry-packages-npm-production"},"readme":"# shell-quote <sup>[![Version Badge][npm-version-svg]][package-url]</sup>\n\n[![github actions][actions-image]][actions-url]\n[![coverage][codecov-image]][codecov-url]\n[![License][license-image]][license-url]\n[![Downloads][downloads-image]][downloads-url]\n\n[![npm badge][npm-badge-png]][package-url]\n\nParse and quote shell commands.\n\n# example\n\n## quote\n\n```js\nvar quote = require('shell-quote/quote');\nvar s = quote([ 'a', 'b c d', '$f', '\"g\"' ]);\nconsole.log(s);\n```\n\noutput\n\n```\na 'b c d' \\$f '\"g\"'\n```\n\n## parse\n\n```js\nvar parse = require('shell-quote/parse');\nvar xs = parse('a \"b c\" \\\\$def \\'it\\'\\\\\\'\\'s great\\'');\nconsole.dir(xs);\n```\n\noutput\n\n```\n[ 'a', 'b c', '$def', \"it's great\" ]\n```\n\n## parse with an environment variable\n\n```js\nvar parse = require('shell-quote/parse');\nvar xs = parse('beep --boop=\"$PWD\"', { PWD: '/home/robot' });\nconsole.dir(xs);\n```\n\noutput\n\n```\n[ 'beep', '--boop=/home/robot' ]\n```\n\n## parse with custom escape character\n\n```js\nvar parse = require('shell-quote/parse');\nvar xs = parse('beep ^--boop=\"$PWD\"', { PWD: '/home/robot' }, { escape: '^' });\nconsole.dir(xs);\n```\n\noutput\n\n```\n[ 'beep', '--boop=/home/robot' ]\n```\n\n## parse with unquoted variable splitting\n\n```js\nvar parse = require('shell-quote/parse');\nvar xs = parse('a $T', { T: 'c d' }, { splitUnquoted: true });\nconsole.dir(xs);\n```\n\noutput\n\n```\n[ 'a', 'c', 'd' ]\n```\n\n## parsing shell operators\n\n```js\nvar parse = require('shell-quote/parse');\nvar xs = parse('beep || boop > /byte');\nconsole.dir(xs);\n```\n\noutput:\n\n```\n[ 'beep', { op: '||' }, 'boop', { op: '>' }, '/byte' ]\n```\n\n## parsing shell comment\n\n```js\nvar parse = require('shell-quote/parse');\nvar xs = parse('beep > boop # > kaboom');\nconsole.dir(xs);\n```\n\noutput:\n\n```\n[ 'beep', { op: '>' }, 'boop', { comment: ' > kaboom' } ]\n```\n\n# methods\n\n```js\nvar quote = require('shell-quote/quote');\nvar parse = require('shell-quote/parse');\n```\n\n## quote(args)\n\nReturn a quoted string for the array `args` suitable for using in shell\ncommands.\n\nEach entry of `args` may be a string, or one of the object shapes that\n`parse` emits: `{ op }` (where `op` is one of the control operators\n`||`, `&&`, `;;`, `|&`, `<(`, `<<<`, `>>`, `>&`, `<&`, `&`, `;`, `(`,\n`)`, `|`, `<`, `>`), `{ op: 'glob', pattern }`, or `{ comment }`. Any\nother object shape, an unrecognized `op`, or a `pattern`/`comment`\ncontaining line terminators throws a `TypeError`.\n\nThe output is POSIX shell (`sh`/`bash`) quoting.\nIt is not valid for Windows `cmd.exe` or PowerShell,\nwhose rules differ and, for `cmd.exe`,\nare not solvable in the general case. On Windows,\ndo not build a shell command string from this output;\ninstead pass an argument array to a non-shell API such as\n`child_process.execFile` or `spawn`\n(or the `cross-spawn` package),\nwhich does no shell parsing and needs no quoting.\n\nUse the returned string verbatim as shell input.\nIt is already a complete, escaped shell word (or words);\ndo not wrap it in additional quotes or embed it in `eval '...'`.\nRe-quoting the output (for example, placing it inside single quotes)\nturns its backslash escapes into literal characters and corrupts the value.\n\n## parse(cmd, env={})\n\nReturn an array of arguments from the quoted string `cmd`.\n\nInterpolate embedded bash-style `$VARNAME` and `${VARNAME}` variables with\nthe `env` object which like bash will replace undefined variables with `\"\"`.\n\nBy default an expanded variable is a single token even when unquoted.\nPass `{ splitUnquoted: true }` to split an unquoted expansion into multiple tokens the way a shell performs field splitting,\nusing the default `IFS` (space, tab, newline).\nPass a string to use its characters as the `IFS` instead\n(for example `{ splitUnquoted: ':' }`).\nA quoted expansion (`\"$VAR\"`) is never split.\n\nOnly simple `$VARNAME` and `${VARNAME}` interpolation is supported.\nBash parameter expansion beyond a plain variable name is not evaluated:\nforms such as array subscripts (`${arr[i]}`), length (`${#arr[@]}`),\nand modifiers (`${var:-default}`, `${var/a/b}`)\nare treated as an unknown variable and expand to `\"\"`,\nwhile arithmetic (`$((...))`) and command substitution (`$(...)`)\nare not interpreted.\nWhitespace inside `${...}` throws a `Bad substitution` error.\n\n`env` is usually an object but it can also be a function to perform lookups.\nWhen `env(key)` returns a string, its result will be output just like `env[key]` would.\nWhen `env(key)` returns an object, it will be inserted into the result\narray like the operator objects.\n\nWhen a bash operator is encountered,\nthe element in the array with be an object with an `\"op\"` key set to the operator string.\nFor example:\n\n```\n'beep || boop > /byte'\n```\n\nparses as:\n\n```\n[ 'beep', { op: '||' }, 'boop', { op: '>' }, '/byte' ]\n```\n\n# install\n\nWith [npm](http://npmjs.org) do:\n\n```\nnpm install shell-quote\n```\n\n# license\n\nMIT\n\n[package-url]: https://npmjs.org/package/shell-quote\n[npm-version-svg]: https://versionbadg.es/ljharb/shell-quote.svg\n[deps-svg]: https://david-dm.org/ljharb/shell-quote.svg\n[deps-url]: https://david-dm.org/ljharb/shell-quote\n[npm-badge-png]: https://nodei.co/npm/shell-quote.png?downloads=true&stars=true\n[license-image]: https://img.shields.io/npm/l/shell-quote.svg\n[license-url]: LICENSE\n[downloads-image]: https://img.shields.io/npm/dm/shell-quote.svg\n[downloads-url]: https://npm-stat.com/charts.html?package=shell-quote\n[codecov-image]: https://codecov.io/gh/ljharb/shell-quote/branch/main/graphs/badge.svg\n[codecov-url]: https://app.codecov.io/gh/ljharb/shell-quote/\n[actions-image]: https://img.shields.io/github/check-runs/ljharb/shell-quote/main\n[actions-url]: https://github.com/ljharb/shell-quote/actions\n","publish_time":1748840585889,"_cnpm_publish_time":1748840585889,"dist-tags":{"latest":"1.12.0"}}