shell-quote

WebJar for shell-quote

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

shell-quote
Last Version

Last Version

1.7.2
Release Date

Release Date

Type

Type

jar
Description

Description

shell-quote
WebJar for shell-quote
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/substack/node-shell-quote

Download shell-quote

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/shell-quote/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>shell-quote</artifactId>
    <version>1.7.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/shell-quote/
implementation 'org.webjars.npm:shell-quote:1.7.2'
// https://jarcasting.com/artifacts/org.webjars.npm/shell-quote/
implementation ("org.webjars.npm:shell-quote:1.7.2")
'org.webjars.npm:shell-quote:jar:1.7.2'
<dependency org="org.webjars.npm" name="shell-quote" rev="1.7.2">
  <artifact name="shell-quote" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='shell-quote', version='1.7.2')
)
libraryDependencies += "org.webjars.npm" % "shell-quote" % "1.7.2"
[org.webjars.npm/shell-quote "1.7.2"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

shell-quote

Parse and quote shell commands.

example

quote

var quote = require('shell-quote').quote;
var s = quote([ 'a', 'b c d', '$f', '"g"' ]);
console.log(s);

output

a 'b c d' \$f '"g"'

parse

var parse = require('shell-quote').parse;
var xs = parse('a "b c" \\$def \'it\\\'s great\'');
console.dir(xs);

output

[ 'a', 'b c', '\\$def', 'it\'s great' ]

parse with an environment variable

var parse = require('shell-quote').parse;
var xs = parse('beep --boop="$PWD"', { PWD: '/home/robot' });
console.dir(xs);

output

[ 'beep', '--boop=/home/robot' ]

parse with custom escape character

var parse = require('shell-quote').parse;
var xs = parse('beep --boop="$PWD"', { PWD: '/home/robot' }, { escape: '^' });
console.dir(xs);

output

[ 'beep', '--boop=/home/robot' ]

parsing shell operators

var parse = require('shell-quote').parse;
var xs = parse('beep || boop > /byte');
console.dir(xs);

output:

[ 'beep', { op: '||' }, 'boop', { op: '>' }, '/byte' ]

parsing shell comment

var parse = require('shell-quote').parse;
var xs = parse('beep > boop # > kaboom');
console.dir(xs);

output:

[ 'beep', { op: '>' }, 'boop', { comment: '> kaboom' } ]

methods

var quote = require('shell-quote').quote;
var parse = require('shell-quote').parse;

quote(args)

Return a quoted string for the array args suitable for using in shell commands.

parse(cmd, env={})

Return an array of arguments from the quoted string cmd.

Interpolate embedded bash-style $VARNAME and ${VARNAME} variables with the env object which like bash will replace undefined variables with "".

env is usually an object but it can also be a function to perform lookups. When env(key) returns a string, its result will be output just like env[key] would. When env(key) returns an object, it will be inserted into the result array like the operator objects.

When a bash operator is encountered, the element in the array with be an object with an "op" key set to the operator string. For example:

'beep || boop > /byte'

parses as:

[ 'beep', { op: '||' }, 'boop', { op: '>' }, '/byte' ]

install

With npm do:

npm install shell-quote

license

MIT

Versions

Version
1.7.2
1.6.1
1.4.3