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 ANSI-C quoting
var parse = require('shell-quote/parse');
var xs = parse("echo
output
[ 'echo', "it's a \n test" ]
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' ]
parse with unquoted variable splitting
var parse = require('shell-quote/parse');
var xs = parse('a $T', { T: 'c d' }, { splitUnquoted: true });
console.dir(xs);
output
[ 'a', 'c', 'd' ]
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.
Each entry of args may be a string, or one of the object shapes that
parse emits: { op } (where op is one of the control operators
||, &&, ;;&, ;;, ;&, |&, <(, >(, <<<, <<-,
<<, >>, >&, >|, &>>, &>, <&, <>, &, ;, (,
), |, <, >),
{ op: 'glob', pattern }, or { comment }. Any
other object shape, an unrecognized op, a pattern/comment
containing line terminators, or a string containing line terminators
anywhere after a { comment } throws a TypeError.
The output is POSIX shell (sh/bash) quoting.
It is not valid for Windows cmd.exe or PowerShell,
whose rules differ and, for cmd.exe,
are not solvable in the general case. On Windows,
do not build a shell command string from this output;
instead pass an argument array to a non-shell API such as
child_process.execFile or spawn
(or the cross-spawn package),
which does no shell parsing and needs no quoting.
Use the returned string verbatim as shell input.
It is already a complete, escaped shell word (or words);
do not wrap it in additional quotes or embed it in eval '...'.
Re-quoting the output (for example, placing it inside single quotes)
turns its backslash escapes into literal characters and corrupts the value.
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 "".
By default an expanded variable is a single token even when unquoted.
Pass { splitUnquoted: true } to split an unquoted expansion into multiple tokens the way a shell performs field splitting,
using the default IFS (space, tab, newline).
Pass a string to use its characters as the IFS instead
(for example { splitUnquoted: ':' }).
A quoted expansion ("$VAR") is never split.
Bash ANSI-C quoting
() is supported: escape sequences (such as \n, \t, \\, \', \",
\xHH, \uHHHH, \UHHHHHHHH, \nnn, and \cx) are decoded, an unrecognized
escape keeps its backslash, and the contents are never word-split and never
variable-expanded, so ${VAR} inside stays literal. As in bash,
is not special inside double or single quotes, and a NUL ends the string.
Since the result is a JavaScript string, \xHH and \nnn produce the character
with that code (U+0000 to U+00FF), not a raw byte.
Only simple $VARNAME and ${VARNAME} interpolation is supported.
Bash parameter expansion beyond a plain variable name is not evaluated:
forms such as array subscripts (${arr[i]}), length (${#arr[@]}),
and modifiers (${var:-default}, ${var/a/b})
are treated as an unknown variable and expand to "",
while arithmetic ($((...))) and command substitution ($(...))
are not interpreted.
Whitespace inside ${...} throws a Bad substitution error.
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' ]
The here-document operators (<< and <<-) are emitted like any other operator,
followed by the delimiter word.
The here-document body is not recognized:
a newline is whitespace to parse,
so the lines after the command are parsed as ordinary tokens,
subject to quoting, comments, globs, and variable expansion.
install
With npm do:
npm install shell-quote
license
MIT
it\\'s a \\n test'");
console.dir(xs);
output
__CODE_BLOCK_5__parse with an environment variable
__CODE_BLOCK_6__output
__CODE_BLOCK_7__parse with custom escape character
__CODE_BLOCK_8__output
__CODE_BLOCK_9__parse with unquoted variable splitting
__CODE_BLOCK_10__output
__CODE_BLOCK_11__parsing shell operators
__CODE_BLOCK_12__output:
__CODE_BLOCK_13__parsing shell comment
__CODE_BLOCK_14__output:
__CODE_BLOCK_15__methods
__CODE_BLOCK_16__quote(args)
Return a quoted string for the array __INLINE_CODE_0__ suitable for using in shell commands.
Each entry of __INLINE_CODE_1__ may be a string, or one of the object shapes that __INLINE_CODE_2__ emits: __INLINE_CODE_3__ (where __INLINE_CODE_4__ is one of the control operators __INLINE_CODE_5__, __INLINE_CODE_6__, __INLINE_CODE_7__, __INLINE_CODE_8__, __INLINE_CODE_9__, __INLINE_CODE_10__, __INLINE_CODE_11__, __INLINE_CODE_12__, __INLINE_CODE_13__, __INLINE_CODE_14__, __INLINE_CODE_15__, __INLINE_CODE_16__, __INLINE_CODE_17__, __INLINE_CODE_18__, __INLINE_CODE_19__, __INLINE_CODE_20__, __INLINE_CODE_21__, __INLINE_CODE_22__, __INLINE_CODE_23__, __INLINE_CODE_24__, __INLINE_CODE_25__, __INLINE_CODE_26__, __INLINE_CODE_27__, __INLINE_CODE_28__, __INLINE_CODE_29__), __INLINE_CODE_30__, or __INLINE_CODE_31__. Any other object shape, an unrecognized __INLINE_CODE_32__, a __INLINE_CODE_33__/__INLINE_CODE_34__ containing line terminators, or a string containing line terminators anywhere after a __INLINE_CODE_35__ throws a __INLINE_CODE_36__.
The output is POSIX shell (__INLINE_CODE_37__/__INLINE_CODE_38__) quoting. It is not valid for Windows __INLINE_CODE_39__ or PowerShell, whose rules differ and, for __INLINE_CODE_40__, are not solvable in the general case. On Windows, do not build a shell command string from this output; instead pass an argument array to a non-shell API such as __INLINE_CODE_41__ or __INLINE_CODE_42__ (or the __INLINE_CODE_43__ package), which does no shell parsing and needs no quoting.
Use the returned string verbatim as shell input. It is already a complete, escaped shell word (or words); do not wrap it in additional quotes or embed it in __INLINE_CODE_44__. Re-quoting the output (for example, placing it inside single quotes) turns its backslash escapes into literal characters and corrupts the value.
parse(cmd, env={})
Return an array of arguments from the quoted string __INLINE_CODE_45__.
Interpolate embedded bash-style __INLINE_CODE_46__ and __INLINE_CODE_47__ variables with the __INLINE_CODE_48__ object which like bash will replace undefined variables with __INLINE_CODE_49__.
By default an expanded variable is a single token even when unquoted. Pass __INLINE_CODE_50__ to split an unquoted expansion into multiple tokens the way a shell performs field splitting, using the default __INLINE_CODE_51__ (space, tab, newline). Pass a string to use its characters as the __INLINE_CODE_52__ instead (for example __INLINE_CODE_53__). A quoted expansion (__INLINE_CODE_54__) is never split.
Bash ANSI-C quoting (__INLINE_CODE_55__) is supported: escape sequences (such as __INLINE_CODE_56__, __INLINE_CODE_57__, __INLINE_CODE_58__, __INLINE_CODE_59__, __INLINE_CODE_60__, __INLINE_CODE_61__, __INLINE_CODE_62__, __INLINE_CODE_63__, __INLINE_CODE_64__, and __INLINE_CODE_65__) are decoded, an unrecognized escape keeps its backslash, and the contents are never word-split and never variable-expanded, so __INLINE_CODE_66__ inside __INLINE_CODE_67__ stays literal. As in bash, __INLINE_CODE_68__ is not special inside double or single quotes, and a NUL ends the string. Since the result is a JavaScript string, __INLINE_CODE_69__ and __INLINE_CODE_70__ produce the character with that code (U+0000 to U+00FF), not a raw byte.
Only simple __INLINE_CODE_71__ and __INLINE_CODE_72__ interpolation is supported. Bash parameter expansion beyond a plain variable name is not evaluated: forms such as array subscripts (__INLINE_CODE_73__), length (__INLINE_CODE_74__), and modifiers (__INLINE_CODE_75__, __INLINE_CODE_76__) are treated as an unknown variable and expand to __INLINE_CODE_77__, while arithmetic (__INLINE_CODE_78__) and command substitution (__INLINE_CODE_79__) are not interpreted. Whitespace inside __INLINE_CODE_80__ throws a __INLINE_CODE_81__ error.
__INLINE_CODE_82__ is usually an object but it can also be a function to perform lookups. When __INLINE_CODE_83__ returns a string, its result will be output just like __INLINE_CODE_84__ would. When __INLINE_CODE_85__ 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 __INLINE_CODE_86__ key set to the operator string. For example:
__CODE_BLOCK_17__parses as:
__CODE_BLOCK_18__The here-document operators (__INLINE_CODE_87__ and __INLINE_CODE_88__) are emitted like any other operator, followed by the delimiter word. The here-document body is not recognized: a newline is whitespace to __INLINE_CODE_89__, so the lines after the command are parsed as ordinary tokens, subject to quoting, comments, globs, and variable expansion.
install
With npm do:
__CODE_BLOCK_19__license
MIT
...') is supported: escape sequences (such as __INLINE_CODE_56__, __INLINE_CODE_57__, __INLINE_CODE_58__, __INLINE_CODE_59__, __INLINE_CODE_60__, __INLINE_CODE_61__, __INLINE_CODE_62__, __INLINE_CODE_63__, __INLINE_CODE_64__, and __INLINE_CODE_65__) are decoded, an unrecognized escape keeps its backslash, and the contents are never word-split and never variable-expanded, so __INLINE_CODE_66__ inside __INLINE_CODE_67__ stays literal. As in bash, __INLINE_CODE_68__ is not special inside double or single quotes, and a NUL ends the string. Since the result is a JavaScript string, __INLINE_CODE_69__ and __INLINE_CODE_70__ produce the character with that code (U+0000 to U+00FF), not a raw byte.Only simple __INLINE_CODE_71__ and __INLINE_CODE_72__ interpolation is supported. Bash parameter expansion beyond a plain variable name is not evaluated: forms such as array subscripts (__INLINE_CODE_73__), length (__INLINE_CODE_74__), and modifiers (__INLINE_CODE_75__, __INLINE_CODE_76__) are treated as an unknown variable and expand to __INLINE_CODE_77__, while arithmetic (__INLINE_CODE_78__) and command substitution (__INLINE_CODE_79__) are not interpreted. Whitespace inside __INLINE_CODE_80__ throws a __INLINE_CODE_81__ error.
__INLINE_CODE_82__ is usually an object but it can also be a function to perform lookups. When __INLINE_CODE_83__ returns a string, its result will be output just like __INLINE_CODE_84__ would. When __INLINE_CODE_85__ 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 __INLINE_CODE_86__ key set to the operator string. For example:
'beep || boop > /byte'
parses as:
[ 'beep', { op: '||' }, 'boop', { op: '>' }, '/byte' ]
The here-document operators (__INLINE_CODE_87__ and __INLINE_CODE_88__) are emitted like any other operator, followed by the delimiter word. The here-document body is not recognized: a newline is whitespace to __INLINE_CODE_89__, so the lines after the command are parsed as ordinary tokens, subject to quoting, comments, globs, and variable expansion.
install
With npm do:
npm install shell-quote
license
MIT
it\\'s a \\n test'"); console.dir(xs);output
__CODE_BLOCK_5__parse with an environment variable
__CODE_BLOCK_6__output
__CODE_BLOCK_7__parse with custom escape character
__CODE_BLOCK_8__output
__CODE_BLOCK_9__parse with unquoted variable splitting
__CODE_BLOCK_10__output
__CODE_BLOCK_11__parsing shell operators
__CODE_BLOCK_12__output:
__CODE_BLOCK_13__parsing shell comment
__CODE_BLOCK_14__output:
__CODE_BLOCK_15__methods
__CODE_BLOCK_16__quote(args)
Return a quoted string for the array __INLINE_CODE_0__ suitable for using in shell commands.
Each entry of __INLINE_CODE_1__ may be a string, or one of the object shapes that __INLINE_CODE_2__ emits: __INLINE_CODE_3__ (where __INLINE_CODE_4__ is one of the control operators __INLINE_CODE_5__, __INLINE_CODE_6__, __INLINE_CODE_7__, __INLINE_CODE_8__, __INLINE_CODE_9__, __INLINE_CODE_10__, __INLINE_CODE_11__, __INLINE_CODE_12__, __INLINE_CODE_13__, __INLINE_CODE_14__, __INLINE_CODE_15__, __INLINE_CODE_16__, __INLINE_CODE_17__, __INLINE_CODE_18__, __INLINE_CODE_19__, __INLINE_CODE_20__, __INLINE_CODE_21__, __INLINE_CODE_22__, __INLINE_CODE_23__, __INLINE_CODE_24__, __INLINE_CODE_25__, __INLINE_CODE_26__, __INLINE_CODE_27__, __INLINE_CODE_28__, __INLINE_CODE_29__), __INLINE_CODE_30__, or __INLINE_CODE_31__. Any other object shape, an unrecognized __INLINE_CODE_32__, a __INLINE_CODE_33__/__INLINE_CODE_34__ containing line terminators, or a string containing line terminators anywhere after a __INLINE_CODE_35__ throws a __INLINE_CODE_36__.
The output is POSIX shell (__INLINE_CODE_37__/__INLINE_CODE_38__) quoting. It is not valid for Windows __INLINE_CODE_39__ or PowerShell, whose rules differ and, for __INLINE_CODE_40__, are not solvable in the general case. On Windows, do not build a shell command string from this output; instead pass an argument array to a non-shell API such as __INLINE_CODE_41__ or __INLINE_CODE_42__ (or the __INLINE_CODE_43__ package), which does no shell parsing and needs no quoting.
Use the returned string verbatim as shell input. It is already a complete, escaped shell word (or words); do not wrap it in additional quotes or embed it in __INLINE_CODE_44__. Re-quoting the output (for example, placing it inside single quotes) turns its backslash escapes into literal characters and corrupts the value.
parse(cmd, env={})
Return an array of arguments from the quoted string __INLINE_CODE_45__.
Interpolate embedded bash-style __INLINE_CODE_46__ and __INLINE_CODE_47__ variables with the __INLINE_CODE_48__ object which like bash will replace undefined variables with __INLINE_CODE_49__.
By default an expanded variable is a single token even when unquoted. Pass __INLINE_CODE_50__ to split an unquoted expansion into multiple tokens the way a shell performs field splitting, using the default __INLINE_CODE_51__ (space, tab, newline). Pass a string to use its characters as the __INLINE_CODE_52__ instead (for example __INLINE_CODE_53__). A quoted expansion (__INLINE_CODE_54__) is never split.
Bash ANSI-C quoting (__INLINE_CODE_55__) is supported: escape sequences (such as __INLINE_CODE_56__, __INLINE_CODE_57__, __INLINE_CODE_58__, __INLINE_CODE_59__, __INLINE_CODE_60__, __INLINE_CODE_61__, __INLINE_CODE_62__, __INLINE_CODE_63__, __INLINE_CODE_64__, and __INLINE_CODE_65__) are decoded, an unrecognized escape keeps its backslash, and the contents are never word-split and never variable-expanded, so __INLINE_CODE_66__ inside __INLINE_CODE_67__ stays literal. As in bash, __INLINE_CODE_68__ is not special inside double or single quotes, and a NUL ends the string. Since the result is a JavaScript string, __INLINE_CODE_69__ and __INLINE_CODE_70__ produce the character with that code (U+0000 to U+00FF), not a raw byte.
Only simple __INLINE_CODE_71__ and __INLINE_CODE_72__ interpolation is supported. Bash parameter expansion beyond a plain variable name is not evaluated: forms such as array subscripts (__INLINE_CODE_73__), length (__INLINE_CODE_74__), and modifiers (__INLINE_CODE_75__, __INLINE_CODE_76__) are treated as an unknown variable and expand to __INLINE_CODE_77__, while arithmetic (__INLINE_CODE_78__) and command substitution (__INLINE_CODE_79__) are not interpreted. Whitespace inside __INLINE_CODE_80__ throws a __INLINE_CODE_81__ error.
__INLINE_CODE_82__ is usually an object but it can also be a function to perform lookups. When __INLINE_CODE_83__ returns a string, its result will be output just like __INLINE_CODE_84__ would. When __INLINE_CODE_85__ 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 __INLINE_CODE_86__ key set to the operator string. For example:
__CODE_BLOCK_17__parses as:
__CODE_BLOCK_18__The here-document operators (__INLINE_CODE_87__ and __INLINE_CODE_88__) are emitted like any other operator, followed by the delimiter word. The here-document body is not recognized: a newline is whitespace to __INLINE_CODE_89__, so the lines after the command are parsed as ordinary tokens, subject to quoting, comments, globs, and variable expansion.
install
With npm do:
__CODE_BLOCK_19__license
MIT
...' stays literal. As in bash, __INLINE_CODE_68__ is not special inside double or single quotes, and a NUL ends the string. Since the result is a JavaScript string, __INLINE_CODE_69__ and __INLINE_CODE_70__ produce the character with that code (U+0000 to U+00FF), not a raw byte.Only simple __INLINE_CODE_71__ and __INLINE_CODE_72__ interpolation is supported. Bash parameter expansion beyond a plain variable name is not evaluated: forms such as array subscripts (__INLINE_CODE_73__), length (__INLINE_CODE_74__), and modifiers (__INLINE_CODE_75__, __INLINE_CODE_76__) are treated as an unknown variable and expand to __INLINE_CODE_77__, while arithmetic (__INLINE_CODE_78__) and command substitution (__INLINE_CODE_79__) are not interpreted. Whitespace inside __INLINE_CODE_80__ throws a __INLINE_CODE_81__ error.
__INLINE_CODE_82__ is usually an object but it can also be a function to perform lookups. When __INLINE_CODE_83__ returns a string, its result will be output just like __INLINE_CODE_84__ would. When __INLINE_CODE_85__ 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 __INLINE_CODE_86__ key set to the operator string. For example:
'beep || boop > /byte'
parses as:
[ 'beep', { op: '||' }, 'boop', { op: '>' }, '/byte' ]
The here-document operators (__INLINE_CODE_87__ and __INLINE_CODE_88__) are emitted like any other operator, followed by the delimiter word. The here-document body is not recognized: a newline is whitespace to __INLINE_CODE_89__, so the lines after the command are parsed as ordinary tokens, subject to quoting, comments, globs, and variable expansion.
install
With npm do:
npm install shell-quote
license
MIT
it\\'s a \\n test'"); console.dir(xs);output
__CODE_BLOCK_5__parse with an environment variable
__CODE_BLOCK_6__output
__CODE_BLOCK_7__parse with custom escape character
__CODE_BLOCK_8__output
__CODE_BLOCK_9__parse with unquoted variable splitting
__CODE_BLOCK_10__output
__CODE_BLOCK_11__parsing shell operators
__CODE_BLOCK_12__output:
__CODE_BLOCK_13__parsing shell comment
__CODE_BLOCK_14__output:
__CODE_BLOCK_15__methods
__CODE_BLOCK_16__quote(args)
Return a quoted string for the array __INLINE_CODE_0__ suitable for using in shell commands.
Each entry of __INLINE_CODE_1__ may be a string, or one of the object shapes that __INLINE_CODE_2__ emits: __INLINE_CODE_3__ (where __INLINE_CODE_4__ is one of the control operators __INLINE_CODE_5__, __INLINE_CODE_6__, __INLINE_CODE_7__, __INLINE_CODE_8__, __INLINE_CODE_9__, __INLINE_CODE_10__, __INLINE_CODE_11__, __INLINE_CODE_12__, __INLINE_CODE_13__, __INLINE_CODE_14__, __INLINE_CODE_15__, __INLINE_CODE_16__, __INLINE_CODE_17__, __INLINE_CODE_18__, __INLINE_CODE_19__, __INLINE_CODE_20__, __INLINE_CODE_21__, __INLINE_CODE_22__, __INLINE_CODE_23__, __INLINE_CODE_24__, __INLINE_CODE_25__, __INLINE_CODE_26__, __INLINE_CODE_27__, __INLINE_CODE_28__, __INLINE_CODE_29__), __INLINE_CODE_30__, or __INLINE_CODE_31__. Any other object shape, an unrecognized __INLINE_CODE_32__, a __INLINE_CODE_33__/__INLINE_CODE_34__ containing line terminators, or a string containing line terminators anywhere after a __INLINE_CODE_35__ throws a __INLINE_CODE_36__.
The output is POSIX shell (__INLINE_CODE_37__/__INLINE_CODE_38__) quoting. It is not valid for Windows __INLINE_CODE_39__ or PowerShell, whose rules differ and, for __INLINE_CODE_40__, are not solvable in the general case. On Windows, do not build a shell command string from this output; instead pass an argument array to a non-shell API such as __INLINE_CODE_41__ or __INLINE_CODE_42__ (or the __INLINE_CODE_43__ package), which does no shell parsing and needs no quoting.
Use the returned string verbatim as shell input. It is already a complete, escaped shell word (or words); do not wrap it in additional quotes or embed it in __INLINE_CODE_44__. Re-quoting the output (for example, placing it inside single quotes) turns its backslash escapes into literal characters and corrupts the value.
parse(cmd, env={})
Return an array of arguments from the quoted string __INLINE_CODE_45__.
Interpolate embedded bash-style __INLINE_CODE_46__ and __INLINE_CODE_47__ variables with the __INLINE_CODE_48__ object which like bash will replace undefined variables with __INLINE_CODE_49__.
By default an expanded variable is a single token even when unquoted. Pass __INLINE_CODE_50__ to split an unquoted expansion into multiple tokens the way a shell performs field splitting, using the default __INLINE_CODE_51__ (space, tab, newline). Pass a string to use its characters as the __INLINE_CODE_52__ instead (for example __INLINE_CODE_53__). A quoted expansion (__INLINE_CODE_54__) is never split.
Bash ANSI-C quoting (__INLINE_CODE_55__) is supported: escape sequences (such as __INLINE_CODE_56__, __INLINE_CODE_57__, __INLINE_CODE_58__, __INLINE_CODE_59__, __INLINE_CODE_60__, __INLINE_CODE_61__, __INLINE_CODE_62__, __INLINE_CODE_63__, __INLINE_CODE_64__, and __INLINE_CODE_65__) are decoded, an unrecognized escape keeps its backslash, and the contents are never word-split and never variable-expanded, so __INLINE_CODE_66__ inside __INLINE_CODE_67__ stays literal. As in bash, __INLINE_CODE_68__ is not special inside double or single quotes, and a NUL ends the string. Since the result is a JavaScript string, __INLINE_CODE_69__ and __INLINE_CODE_70__ produce the character with that code (U+0000 to U+00FF), not a raw byte.
Only simple __INLINE_CODE_71__ and __INLINE_CODE_72__ interpolation is supported. Bash parameter expansion beyond a plain variable name is not evaluated: forms such as array subscripts (__INLINE_CODE_73__), length (__INLINE_CODE_74__), and modifiers (__INLINE_CODE_75__, __INLINE_CODE_76__) are treated as an unknown variable and expand to __INLINE_CODE_77__, while arithmetic (__INLINE_CODE_78__) and command substitution (__INLINE_CODE_79__) are not interpreted. Whitespace inside __INLINE_CODE_80__ throws a __INLINE_CODE_81__ error.
__INLINE_CODE_82__ is usually an object but it can also be a function to perform lookups. When __INLINE_CODE_83__ returns a string, its result will be output just like __INLINE_CODE_84__ would. When __INLINE_CODE_85__ 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 __INLINE_CODE_86__ key set to the operator string. For example:
__CODE_BLOCK_17__parses as:
__CODE_BLOCK_18__The here-document operators (__INLINE_CODE_87__ and __INLINE_CODE_88__) are emitted like any other operator, followed by the delimiter word. The here-document body is not recognized: a newline is whitespace to __INLINE_CODE_89__, so the lines after the command are parsed as ordinary tokens, subject to quoting, comments, globs, and variable expansion.
install
With npm do:
__CODE_BLOCK_19__license
MIT
...') is supported: escape sequences (such as __INLINE_CODE_56__, __INLINE_CODE_57__, __INLINE_CODE_58__, __INLINE_CODE_59__, __INLINE_CODE_60__, __INLINE_CODE_61__, __INLINE_CODE_62__, __INLINE_CODE_63__, __INLINE_CODE_64__, and __INLINE_CODE_65__) are decoded, an unrecognized escape keeps its backslash, and the contents are never word-split and never variable-expanded, so __INLINE_CODE_66__ inside __INLINE_CODE_67__ stays literal. As in bash, __INLINE_CODE_68__ is not special inside double or single quotes, and a NUL ends the string. Since the result is a JavaScript string, __INLINE_CODE_69__ and __INLINE_CODE_70__ produce the character with that code (U+0000 to U+00FF), not a raw byte.Only simple __INLINE_CODE_71__ and __INLINE_CODE_72__ interpolation is supported. Bash parameter expansion beyond a plain variable name is not evaluated: forms such as array subscripts (__INLINE_CODE_73__), length (__INLINE_CODE_74__), and modifiers (__INLINE_CODE_75__, __INLINE_CODE_76__) are treated as an unknown variable and expand to __INLINE_CODE_77__, while arithmetic (__INLINE_CODE_78__) and command substitution (__INLINE_CODE_79__) are not interpreted. Whitespace inside __INLINE_CODE_80__ throws a __INLINE_CODE_81__ error.
__INLINE_CODE_82__ is usually an object but it can also be a function to perform lookups. When __INLINE_CODE_83__ returns a string, its result will be output just like __INLINE_CODE_84__ would. When __INLINE_CODE_85__ 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 __INLINE_CODE_86__ key set to the operator string. For example:
'beep || boop > /byte'
parses as:
[ 'beep', { op: '||' }, 'boop', { op: '>' }, '/byte' ]
The here-document operators (__INLINE_CODE_87__ and __INLINE_CODE_88__) are emitted like any other operator, followed by the delimiter word. The here-document body is not recognized: a newline is whitespace to __INLINE_CODE_89__, so the lines after the command are parsed as ordinary tokens, subject to quoting, comments, globs, and variable expansion.
install
With npm do:
npm install shell-quote
license
MIT
it\\'s a \\n test'"); console.dir(xs);output
__CODE_BLOCK_5__parse with an environment variable
__CODE_BLOCK_6__output
__CODE_BLOCK_7__parse with custom escape character
__CODE_BLOCK_8__output
__CODE_BLOCK_9__parse with unquoted variable splitting
__CODE_BLOCK_10__output
__CODE_BLOCK_11__parsing shell operators
__CODE_BLOCK_12__output:
__CODE_BLOCK_13__parsing shell comment
__CODE_BLOCK_14__output:
__CODE_BLOCK_15__methods
__CODE_BLOCK_16__quote(args)
Return a quoted string for the array __INLINE_CODE_0__ suitable for using in shell commands.
Each entry of __INLINE_CODE_1__ may be a string, or one of the object shapes that __INLINE_CODE_2__ emits: __INLINE_CODE_3__ (where __INLINE_CODE_4__ is one of the control operators __INLINE_CODE_5__, __INLINE_CODE_6__, __INLINE_CODE_7__, __INLINE_CODE_8__, __INLINE_CODE_9__, __INLINE_CODE_10__, __INLINE_CODE_11__, __INLINE_CODE_12__, __INLINE_CODE_13__, __INLINE_CODE_14__, __INLINE_CODE_15__, __INLINE_CODE_16__, __INLINE_CODE_17__, __INLINE_CODE_18__, __INLINE_CODE_19__, __INLINE_CODE_20__, __INLINE_CODE_21__, __INLINE_CODE_22__, __INLINE_CODE_23__, __INLINE_CODE_24__, __INLINE_CODE_25__, __INLINE_CODE_26__, __INLINE_CODE_27__, __INLINE_CODE_28__, __INLINE_CODE_29__), __INLINE_CODE_30__, or __INLINE_CODE_31__. Any other object shape, an unrecognized __INLINE_CODE_32__, a __INLINE_CODE_33__/__INLINE_CODE_34__ containing line terminators, or a string containing line terminators anywhere after a __INLINE_CODE_35__ throws a __INLINE_CODE_36__.
The output is POSIX shell (__INLINE_CODE_37__/__INLINE_CODE_38__) quoting. It is not valid for Windows __INLINE_CODE_39__ or PowerShell, whose rules differ and, for __INLINE_CODE_40__, are not solvable in the general case. On Windows, do not build a shell command string from this output; instead pass an argument array to a non-shell API such as __INLINE_CODE_41__ or __INLINE_CODE_42__ (or the __INLINE_CODE_43__ package), which does no shell parsing and needs no quoting.
Use the returned string verbatim as shell input. It is already a complete, escaped shell word (or words); do not wrap it in additional quotes or embed it in __INLINE_CODE_44__. Re-quoting the output (for example, placing it inside single quotes) turns its backslash escapes into literal characters and corrupts the value.
parse(cmd, env={})
Return an array of arguments from the quoted string __INLINE_CODE_45__.
Interpolate embedded bash-style __INLINE_CODE_46__ and __INLINE_CODE_47__ variables with the __INLINE_CODE_48__ object which like bash will replace undefined variables with __INLINE_CODE_49__.
By default an expanded variable is a single token even when unquoted. Pass __INLINE_CODE_50__ to split an unquoted expansion into multiple tokens the way a shell performs field splitting, using the default __INLINE_CODE_51__ (space, tab, newline). Pass a string to use its characters as the __INLINE_CODE_52__ instead (for example __INLINE_CODE_53__). A quoted expansion (__INLINE_CODE_54__) is never split.
Bash ANSI-C quoting (__INLINE_CODE_55__) is supported: escape sequences (such as __INLINE_CODE_56__, __INLINE_CODE_57__, __INLINE_CODE_58__, __INLINE_CODE_59__, __INLINE_CODE_60__, __INLINE_CODE_61__, __INLINE_CODE_62__, __INLINE_CODE_63__, __INLINE_CODE_64__, and __INLINE_CODE_65__) are decoded, an unrecognized escape keeps its backslash, and the contents are never word-split and never variable-expanded, so __INLINE_CODE_66__ inside __INLINE_CODE_67__ stays literal. As in bash, __INLINE_CODE_68__ is not special inside double or single quotes, and a NUL ends the string. Since the result is a JavaScript string, __INLINE_CODE_69__ and __INLINE_CODE_70__ produce the character with that code (U+0000 to U+00FF), not a raw byte.
Only simple __INLINE_CODE_71__ and __INLINE_CODE_72__ interpolation is supported. Bash parameter expansion beyond a plain variable name is not evaluated: forms such as array subscripts (__INLINE_CODE_73__), length (__INLINE_CODE_74__), and modifiers (__INLINE_CODE_75__, __INLINE_CODE_76__) are treated as an unknown variable and expand to __INLINE_CODE_77__, while arithmetic (__INLINE_CODE_78__) and command substitution (__INLINE_CODE_79__) are not interpreted. Whitespace inside __INLINE_CODE_80__ throws a __INLINE_CODE_81__ error.
__INLINE_CODE_82__ is usually an object but it can also be a function to perform lookups. When __INLINE_CODE_83__ returns a string, its result will be output just like __INLINE_CODE_84__ would. When __INLINE_CODE_85__ 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 __INLINE_CODE_86__ key set to the operator string. For example:
__CODE_BLOCK_17__parses as:
__CODE_BLOCK_18__The here-document operators (__INLINE_CODE_87__ and __INLINE_CODE_88__) are emitted like any other operator, followed by the delimiter word. The here-document body is not recognized: a newline is whitespace to __INLINE_CODE_89__, so the lines after the command are parsed as ordinary tokens, subject to quoting, comments, globs, and variable expansion.
install
With npm do:
__CODE_BLOCK_19__license
MIT
...' is not special inside double or single quotes, and a NUL ends the string. Since the result is a JavaScript string, __INLINE_CODE_69__ and __INLINE_CODE_70__ produce the character with that code (U+0000 to U+00FF), not a raw byte.Only simple __INLINE_CODE_71__ and __INLINE_CODE_72__ interpolation is supported. Bash parameter expansion beyond a plain variable name is not evaluated: forms such as array subscripts (__INLINE_CODE_73__), length (__INLINE_CODE_74__), and modifiers (__INLINE_CODE_75__, __INLINE_CODE_76__) are treated as an unknown variable and expand to __INLINE_CODE_77__, while arithmetic (__INLINE_CODE_78__) and command substitution (__INLINE_CODE_79__) are not interpreted. Whitespace inside __INLINE_CODE_80__ throws a __INLINE_CODE_81__ error.
__INLINE_CODE_82__ is usually an object but it can also be a function to perform lookups. When __INLINE_CODE_83__ returns a string, its result will be output just like __INLINE_CODE_84__ would. When __INLINE_CODE_85__ 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 __INLINE_CODE_86__ key set to the operator string. For example:
'beep || boop > /byte'
parses as:
[ 'beep', { op: '||' }, 'boop', { op: '>' }, '/byte' ]
The here-document operators (__INLINE_CODE_87__ and __INLINE_CODE_88__) are emitted like any other operator, followed by the delimiter word. The here-document body is not recognized: a newline is whitespace to __INLINE_CODE_89__, so the lines after the command are parsed as ordinary tokens, subject to quoting, comments, globs, and variable expansion.
install
With npm do:
npm install shell-quote
license
MIT
it\\'s a \\n test'"); console.dir(xs);output
__CODE_BLOCK_5__parse with an environment variable
__CODE_BLOCK_6__output
__CODE_BLOCK_7__parse with custom escape character
__CODE_BLOCK_8__output
__CODE_BLOCK_9__parse with unquoted variable splitting
__CODE_BLOCK_10__output
__CODE_BLOCK_11__parsing shell operators
__CODE_BLOCK_12__output:
__CODE_BLOCK_13__parsing shell comment
__CODE_BLOCK_14__output:
__CODE_BLOCK_15__methods
__CODE_BLOCK_16__quote(args)
Return a quoted string for the array __INLINE_CODE_0__ suitable for using in shell commands.
Each entry of __INLINE_CODE_1__ may be a string, or one of the object shapes that __INLINE_CODE_2__ emits: __INLINE_CODE_3__ (where __INLINE_CODE_4__ is one of the control operators __INLINE_CODE_5__, __INLINE_CODE_6__, __INLINE_CODE_7__, __INLINE_CODE_8__, __INLINE_CODE_9__, __INLINE_CODE_10__, __INLINE_CODE_11__, __INLINE_CODE_12__, __INLINE_CODE_13__, __INLINE_CODE_14__, __INLINE_CODE_15__, __INLINE_CODE_16__, __INLINE_CODE_17__, __INLINE_CODE_18__, __INLINE_CODE_19__, __INLINE_CODE_20__, __INLINE_CODE_21__, __INLINE_CODE_22__, __INLINE_CODE_23__, __INLINE_CODE_24__, __INLINE_CODE_25__, __INLINE_CODE_26__, __INLINE_CODE_27__, __INLINE_CODE_28__, __INLINE_CODE_29__), __INLINE_CODE_30__, or __INLINE_CODE_31__. Any other object shape, an unrecognized __INLINE_CODE_32__, a __INLINE_CODE_33__/__INLINE_CODE_34__ containing line terminators, or a string containing line terminators anywhere after a __INLINE_CODE_35__ throws a __INLINE_CODE_36__.
The output is POSIX shell (__INLINE_CODE_37__/__INLINE_CODE_38__) quoting. It is not valid for Windows __INLINE_CODE_39__ or PowerShell, whose rules differ and, for __INLINE_CODE_40__, are not solvable in the general case. On Windows, do not build a shell command string from this output; instead pass an argument array to a non-shell API such as __INLINE_CODE_41__ or __INLINE_CODE_42__ (or the __INLINE_CODE_43__ package), which does no shell parsing and needs no quoting.
Use the returned string verbatim as shell input. It is already a complete, escaped shell word (or words); do not wrap it in additional quotes or embed it in __INLINE_CODE_44__. Re-quoting the output (for example, placing it inside single quotes) turns its backslash escapes into literal characters and corrupts the value.
parse(cmd, env={})
Return an array of arguments from the quoted string __INLINE_CODE_45__.
Interpolate embedded bash-style __INLINE_CODE_46__ and __INLINE_CODE_47__ variables with the __INLINE_CODE_48__ object which like bash will replace undefined variables with __INLINE_CODE_49__.
By default an expanded variable is a single token even when unquoted. Pass __INLINE_CODE_50__ to split an unquoted expansion into multiple tokens the way a shell performs field splitting, using the default __INLINE_CODE_51__ (space, tab, newline). Pass a string to use its characters as the __INLINE_CODE_52__ instead (for example __INLINE_CODE_53__). A quoted expansion (__INLINE_CODE_54__) is never split.
Bash ANSI-C quoting (__INLINE_CODE_55__) is supported: escape sequences (such as __INLINE_CODE_56__, __INLINE_CODE_57__, __INLINE_CODE_58__, __INLINE_CODE_59__, __INLINE_CODE_60__, __INLINE_CODE_61__, __INLINE_CODE_62__, __INLINE_CODE_63__, __INLINE_CODE_64__, and __INLINE_CODE_65__) are decoded, an unrecognized escape keeps its backslash, and the contents are never word-split and never variable-expanded, so __INLINE_CODE_66__ inside __INLINE_CODE_67__ stays literal. As in bash, __INLINE_CODE_68__ is not special inside double or single quotes, and a NUL ends the string. Since the result is a JavaScript string, __INLINE_CODE_69__ and __INLINE_CODE_70__ produce the character with that code (U+0000 to U+00FF), not a raw byte.
Only simple __INLINE_CODE_71__ and __INLINE_CODE_72__ interpolation is supported. Bash parameter expansion beyond a plain variable name is not evaluated: forms such as array subscripts (__INLINE_CODE_73__), length (__INLINE_CODE_74__), and modifiers (__INLINE_CODE_75__, __INLINE_CODE_76__) are treated as an unknown variable and expand to __INLINE_CODE_77__, while arithmetic (__INLINE_CODE_78__) and command substitution (__INLINE_CODE_79__) are not interpreted. Whitespace inside __INLINE_CODE_80__ throws a __INLINE_CODE_81__ error.
__INLINE_CODE_82__ is usually an object but it can also be a function to perform lookups. When __INLINE_CODE_83__ returns a string, its result will be output just like __INLINE_CODE_84__ would. When __INLINE_CODE_85__ 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 __INLINE_CODE_86__ key set to the operator string. For example:
__CODE_BLOCK_17__parses as:
__CODE_BLOCK_18__The here-document operators (__INLINE_CODE_87__ and __INLINE_CODE_88__) are emitted like any other operator, followed by the delimiter word. The here-document body is not recognized: a newline is whitespace to __INLINE_CODE_89__, so the lines after the command are parsed as ordinary tokens, subject to quoting, comments, globs, and variable expansion.
install
With npm do:
__CODE_BLOCK_19__license
MIT
...') is supported: escape sequences (such as __INLINE_CODE_56__, __INLINE_CODE_57__, __INLINE_CODE_58__, __INLINE_CODE_59__, __INLINE_CODE_60__, __INLINE_CODE_61__, __INLINE_CODE_62__, __INLINE_CODE_63__, __INLINE_CODE_64__, and __INLINE_CODE_65__) are decoded, an unrecognized escape keeps its backslash, and the contents are never word-split and never variable-expanded, so __INLINE_CODE_66__ inside __INLINE_CODE_67__ stays literal. As in bash, __INLINE_CODE_68__ is not special inside double or single quotes, and a NUL ends the string. Since the result is a JavaScript string, __INLINE_CODE_69__ and __INLINE_CODE_70__ produce the character with that code (U+0000 to U+00FF), not a raw byte.Only simple __INLINE_CODE_71__ and __INLINE_CODE_72__ interpolation is supported. Bash parameter expansion beyond a plain variable name is not evaluated: forms such as array subscripts (__INLINE_CODE_73__), length (__INLINE_CODE_74__), and modifiers (__INLINE_CODE_75__, __INLINE_CODE_76__) are treated as an unknown variable and expand to __INLINE_CODE_77__, while arithmetic (__INLINE_CODE_78__) and command substitution (__INLINE_CODE_79__) are not interpreted. Whitespace inside __INLINE_CODE_80__ throws a __INLINE_CODE_81__ error.
__INLINE_CODE_82__ is usually an object but it can also be a function to perform lookups. When __INLINE_CODE_83__ returns a string, its result will be output just like __INLINE_CODE_84__ would. When __INLINE_CODE_85__ 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 __INLINE_CODE_86__ key set to the operator string. For example:
'beep || boop > /byte'
parses as:
[ 'beep', { op: '||' }, 'boop', { op: '>' }, '/byte' ]
The here-document operators (__INLINE_CODE_87__ and __INLINE_CODE_88__) are emitted like any other operator, followed by the delimiter word. The here-document body is not recognized: a newline is whitespace to __INLINE_CODE_89__, so the lines after the command are parsed as ordinary tokens, subject to quoting, comments, globs, and variable expansion.
install
With npm do:
npm install shell-quote
license
MIT
it\\'s a \\n test'"); console.dir(xs);output
__CODE_BLOCK_5__parse with an environment variable
__CODE_BLOCK_6__output
__CODE_BLOCK_7__parse with custom escape character
__CODE_BLOCK_8__output
__CODE_BLOCK_9__parse with unquoted variable splitting
__CODE_BLOCK_10__output
__CODE_BLOCK_11__parsing shell operators
__CODE_BLOCK_12__output:
__CODE_BLOCK_13__parsing shell comment
__CODE_BLOCK_14__output:
__CODE_BLOCK_15__methods
__CODE_BLOCK_16__quote(args)
Return a quoted string for the array __INLINE_CODE_0__ suitable for using in shell commands.
Each entry of __INLINE_CODE_1__ may be a string, or one of the object shapes that __INLINE_CODE_2__ emits: __INLINE_CODE_3__ (where __INLINE_CODE_4__ is one of the control operators __INLINE_CODE_5__, __INLINE_CODE_6__, __INLINE_CODE_7__, __INLINE_CODE_8__, __INLINE_CODE_9__, __INLINE_CODE_10__, __INLINE_CODE_11__, __INLINE_CODE_12__, __INLINE_CODE_13__, __INLINE_CODE_14__, __INLINE_CODE_15__, __INLINE_CODE_16__, __INLINE_CODE_17__, __INLINE_CODE_18__, __INLINE_CODE_19__, __INLINE_CODE_20__, __INLINE_CODE_21__, __INLINE_CODE_22__, __INLINE_CODE_23__, __INLINE_CODE_24__, __INLINE_CODE_25__, __INLINE_CODE_26__, __INLINE_CODE_27__, __INLINE_CODE_28__, __INLINE_CODE_29__), __INLINE_CODE_30__, or __INLINE_CODE_31__. Any other object shape, an unrecognized __INLINE_CODE_32__, a __INLINE_CODE_33__/__INLINE_CODE_34__ containing line terminators, or a string containing line terminators anywhere after a __INLINE_CODE_35__ throws a __INLINE_CODE_36__.
The output is POSIX shell (__INLINE_CODE_37__/__INLINE_CODE_38__) quoting. It is not valid for Windows __INLINE_CODE_39__ or PowerShell, whose rules differ and, for __INLINE_CODE_40__, are not solvable in the general case. On Windows, do not build a shell command string from this output; instead pass an argument array to a non-shell API such as __INLINE_CODE_41__ or __INLINE_CODE_42__ (or the __INLINE_CODE_43__ package), which does no shell parsing and needs no quoting.
Use the returned string verbatim as shell input. It is already a complete, escaped shell word (or words); do not wrap it in additional quotes or embed it in __INLINE_CODE_44__. Re-quoting the output (for example, placing it inside single quotes) turns its backslash escapes into literal characters and corrupts the value.
parse(cmd, env={})
Return an array of arguments from the quoted string __INLINE_CODE_45__.
Interpolate embedded bash-style __INLINE_CODE_46__ and __INLINE_CODE_47__ variables with the __INLINE_CODE_48__ object which like bash will replace undefined variables with __INLINE_CODE_49__.
By default an expanded variable is a single token even when unquoted. Pass __INLINE_CODE_50__ to split an unquoted expansion into multiple tokens the way a shell performs field splitting, using the default __INLINE_CODE_51__ (space, tab, newline). Pass a string to use its characters as the __INLINE_CODE_52__ instead (for example __INLINE_CODE_53__). A quoted expansion (__INLINE_CODE_54__) is never split.
Bash ANSI-C quoting (__INLINE_CODE_55__) is supported: escape sequences (such as __INLINE_CODE_56__, __INLINE_CODE_57__, __INLINE_CODE_58__, __INLINE_CODE_59__, __INLINE_CODE_60__, __INLINE_CODE_61__, __INLINE_CODE_62__, __INLINE_CODE_63__, __INLINE_CODE_64__, and __INLINE_CODE_65__) are decoded, an unrecognized escape keeps its backslash, and the contents are never word-split and never variable-expanded, so __INLINE_CODE_66__ inside __INLINE_CODE_67__ stays literal. As in bash, __INLINE_CODE_68__ is not special inside double or single quotes, and a NUL ends the string. Since the result is a JavaScript string, __INLINE_CODE_69__ and __INLINE_CODE_70__ produce the character with that code (U+0000 to U+00FF), not a raw byte.
Only simple __INLINE_CODE_71__ and __INLINE_CODE_72__ interpolation is supported. Bash parameter expansion beyond a plain variable name is not evaluated: forms such as array subscripts (__INLINE_CODE_73__), length (__INLINE_CODE_74__), and modifiers (__INLINE_CODE_75__, __INLINE_CODE_76__) are treated as an unknown variable and expand to __INLINE_CODE_77__, while arithmetic (__INLINE_CODE_78__) and command substitution (__INLINE_CODE_79__) are not interpreted. Whitespace inside __INLINE_CODE_80__ throws a __INLINE_CODE_81__ error.
__INLINE_CODE_82__ is usually an object but it can also be a function to perform lookups. When __INLINE_CODE_83__ returns a string, its result will be output just like __INLINE_CODE_84__ would. When __INLINE_CODE_85__ 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 __INLINE_CODE_86__ key set to the operator string. For example:
__CODE_BLOCK_17__parses as:
__CODE_BLOCK_18__The here-document operators (__INLINE_CODE_87__ and __INLINE_CODE_88__) are emitted like any other operator, followed by the delimiter word. The here-document body is not recognized: a newline is whitespace to __INLINE_CODE_89__, so the lines after the command are parsed as ordinary tokens, subject to quoting, comments, globs, and variable expansion.
install
With npm do:
__CODE_BLOCK_19__license
MIT
...' stays literal. As in bash, __INLINE_CODE_68__ is not special inside double or single quotes, and a NUL ends the string. Since the result is a JavaScript string, __INLINE_CODE_69__ and __INLINE_CODE_70__ produce the character with that code (U+0000 to U+00FF), not a raw byte.Only simple __INLINE_CODE_71__ and __INLINE_CODE_72__ interpolation is supported. Bash parameter expansion beyond a plain variable name is not evaluated: forms such as array subscripts (__INLINE_CODE_73__), length (__INLINE_CODE_74__), and modifiers (__INLINE_CODE_75__, __INLINE_CODE_76__) are treated as an unknown variable and expand to __INLINE_CODE_77__, while arithmetic (__INLINE_CODE_78__) and command substitution (__INLINE_CODE_79__) are not interpreted. Whitespace inside __INLINE_CODE_80__ throws a __INLINE_CODE_81__ error.
__INLINE_CODE_82__ is usually an object but it can also be a function to perform lookups. When __INLINE_CODE_83__ returns a string, its result will be output just like __INLINE_CODE_84__ would. When __INLINE_CODE_85__ 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 __INLINE_CODE_86__ key set to the operator string. For example:
'beep || boop > /byte'
parses as:
[ 'beep', { op: '||' }, 'boop', { op: '>' }, '/byte' ]
The here-document operators (__INLINE_CODE_87__ and __INLINE_CODE_88__) are emitted like any other operator, followed by the delimiter word. The here-document body is not recognized: a newline is whitespace to __INLINE_CODE_89__, so the lines after the command are parsed as ordinary tokens, subject to quoting, comments, globs, and variable expansion.
install
With npm do:
npm install shell-quote
license
MIT
it\\'s a \\n test'"); console.dir(xs);output
__CODE_BLOCK_5__parse with an environment variable
__CODE_BLOCK_6__output
__CODE_BLOCK_7__parse with custom escape character
__CODE_BLOCK_8__output
__CODE_BLOCK_9__parse with unquoted variable splitting
__CODE_BLOCK_10__output
__CODE_BLOCK_11__parsing shell operators
__CODE_BLOCK_12__output:
__CODE_BLOCK_13__parsing shell comment
__CODE_BLOCK_14__output:
__CODE_BLOCK_15__methods
__CODE_BLOCK_16__quote(args)
Return a quoted string for the array __INLINE_CODE_0__ suitable for using in shell commands.
Each entry of __INLINE_CODE_1__ may be a string, or one of the object shapes that __INLINE_CODE_2__ emits: __INLINE_CODE_3__ (where __INLINE_CODE_4__ is one of the control operators __INLINE_CODE_5__, __INLINE_CODE_6__, __INLINE_CODE_7__, __INLINE_CODE_8__, __INLINE_CODE_9__, __INLINE_CODE_10__, __INLINE_CODE_11__, __INLINE_CODE_12__, __INLINE_CODE_13__, __INLINE_CODE_14__, __INLINE_CODE_15__, __INLINE_CODE_16__, __INLINE_CODE_17__, __INLINE_CODE_18__, __INLINE_CODE_19__, __INLINE_CODE_20__, __INLINE_CODE_21__, __INLINE_CODE_22__, __INLINE_CODE_23__, __INLINE_CODE_24__, __INLINE_CODE_25__, __INLINE_CODE_26__, __INLINE_CODE_27__, __INLINE_CODE_28__, __INLINE_CODE_29__), __INLINE_CODE_30__, or __INLINE_CODE_31__. Any other object shape, an unrecognized __INLINE_CODE_32__, a __INLINE_CODE_33__/__INLINE_CODE_34__ containing line terminators, or a string containing line terminators anywhere after a __INLINE_CODE_35__ throws a __INLINE_CODE_36__.
The output is POSIX shell (__INLINE_CODE_37__/__INLINE_CODE_38__) quoting. It is not valid for Windows __INLINE_CODE_39__ or PowerShell, whose rules differ and, for __INLINE_CODE_40__, are not solvable in the general case. On Windows, do not build a shell command string from this output; instead pass an argument array to a non-shell API such as __INLINE_CODE_41__ or __INLINE_CODE_42__ (or the __INLINE_CODE_43__ package), which does no shell parsing and needs no quoting.
Use the returned string verbatim as shell input. It is already a complete, escaped shell word (or words); do not wrap it in additional quotes or embed it in __INLINE_CODE_44__. Re-quoting the output (for example, placing it inside single quotes) turns its backslash escapes into literal characters and corrupts the value.
parse(cmd, env={})
Return an array of arguments from the quoted string __INLINE_CODE_45__.
Interpolate embedded bash-style __INLINE_CODE_46__ and __INLINE_CODE_47__ variables with the __INLINE_CODE_48__ object which like bash will replace undefined variables with __INLINE_CODE_49__.
By default an expanded variable is a single token even when unquoted. Pass __INLINE_CODE_50__ to split an unquoted expansion into multiple tokens the way a shell performs field splitting, using the default __INLINE_CODE_51__ (space, tab, newline). Pass a string to use its characters as the __INLINE_CODE_52__ instead (for example __INLINE_CODE_53__). A quoted expansion (__INLINE_CODE_54__) is never split.
Bash ANSI-C quoting (__INLINE_CODE_55__) is supported: escape sequences (such as __INLINE_CODE_56__, __INLINE_CODE_57__, __INLINE_CODE_58__, __INLINE_CODE_59__, __INLINE_CODE_60__, __INLINE_CODE_61__, __INLINE_CODE_62__, __INLINE_CODE_63__, __INLINE_CODE_64__, and __INLINE_CODE_65__) are decoded, an unrecognized escape keeps its backslash, and the contents are never word-split and never variable-expanded, so __INLINE_CODE_66__ inside __INLINE_CODE_67__ stays literal. As in bash, __INLINE_CODE_68__ is not special inside double or single quotes, and a NUL ends the string. Since the result is a JavaScript string, __INLINE_CODE_69__ and __INLINE_CODE_70__ produce the character with that code (U+0000 to U+00FF), not a raw byte.
Only simple __INLINE_CODE_71__ and __INLINE_CODE_72__ interpolation is supported. Bash parameter expansion beyond a plain variable name is not evaluated: forms such as array subscripts (__INLINE_CODE_73__), length (__INLINE_CODE_74__), and modifiers (__INLINE_CODE_75__, __INLINE_CODE_76__) are treated as an unknown variable and expand to __INLINE_CODE_77__, while arithmetic (__INLINE_CODE_78__) and command substitution (__INLINE_CODE_79__) are not interpreted. Whitespace inside __INLINE_CODE_80__ throws a __INLINE_CODE_81__ error.
__INLINE_CODE_82__ is usually an object but it can also be a function to perform lookups. When __INLINE_CODE_83__ returns a string, its result will be output just like __INLINE_CODE_84__ would. When __INLINE_CODE_85__ 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 __INLINE_CODE_86__ key set to the operator string. For example:
__CODE_BLOCK_17__parses as:
__CODE_BLOCK_18__The here-document operators (__INLINE_CODE_87__ and __INLINE_CODE_88__) are emitted like any other operator, followed by the delimiter word. The here-document body is not recognized: a newline is whitespace to __INLINE_CODE_89__, so the lines after the command are parsed as ordinary tokens, subject to quoting, comments, globs, and variable expansion.
install
With npm do:
__CODE_BLOCK_19__license
MIT
...') is supported: escape sequences (such as __INLINE_CODE_56__, __INLINE_CODE_57__, __INLINE_CODE_58__, __INLINE_CODE_59__, __INLINE_CODE_60__, __INLINE_CODE_61__, __INLINE_CODE_62__, __INLINE_CODE_63__, __INLINE_CODE_64__, and __INLINE_CODE_65__) are decoded, an unrecognized escape keeps its backslash, and the contents are never word-split and never variable-expanded, so __INLINE_CODE_66__ inside __INLINE_CODE_67__ stays literal. As in bash, __INLINE_CODE_68__ is not special inside double or single quotes, and a NUL ends the string. Since the result is a JavaScript string, __INLINE_CODE_69__ and __INLINE_CODE_70__ produce the character with that code (U+0000 to U+00FF), not a raw byte.Only simple __INLINE_CODE_71__ and __INLINE_CODE_72__ interpolation is supported. Bash parameter expansion beyond a plain variable name is not evaluated: forms such as array subscripts (__INLINE_CODE_73__), length (__INLINE_CODE_74__), and modifiers (__INLINE_CODE_75__, __INLINE_CODE_76__) are treated as an unknown variable and expand to __INLINE_CODE_77__, while arithmetic (__INLINE_CODE_78__) and command substitution (__INLINE_CODE_79__) are not interpreted. Whitespace inside __INLINE_CODE_80__ throws a __INLINE_CODE_81__ error.
__INLINE_CODE_82__ is usually an object but it can also be a function to perform lookups. When __INLINE_CODE_83__ returns a string, its result will be output just like __INLINE_CODE_84__ would. When __INLINE_CODE_85__ 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 __INLINE_CODE_86__ key set to the operator string. For example:
'beep || boop > /byte'
parses as:
[ 'beep', { op: '||' }, 'boop', { op: '>' }, '/byte' ]
The here-document operators (__INLINE_CODE_87__ and __INLINE_CODE_88__) are emitted like any other operator, followed by the delimiter word. The here-document body is not recognized: a newline is whitespace to __INLINE_CODE_89__, so the lines after the command are parsed as ordinary tokens, subject to quoting, comments, globs, and variable expansion.
install
With npm do:
npm install shell-quote
license
MIT
it\\'s a \\n test'"); console.dir(xs);output
__CODE_BLOCK_5__parse with an environment variable
__CODE_BLOCK_6__output
__CODE_BLOCK_7__parse with custom escape character
__CODE_BLOCK_8__output
__CODE_BLOCK_9__parse with unquoted variable splitting
__CODE_BLOCK_10__output
__CODE_BLOCK_11__parsing shell operators
__CODE_BLOCK_12__output:
__CODE_BLOCK_13__parsing shell comment
__CODE_BLOCK_14__output:
__CODE_BLOCK_15__methods
__CODE_BLOCK_16__quote(args)
Return a quoted string for the array __INLINE_CODE_0__ suitable for using in shell commands.
Each entry of __INLINE_CODE_1__ may be a string, or one of the object shapes that __INLINE_CODE_2__ emits: __INLINE_CODE_3__ (where __INLINE_CODE_4__ is one of the control operators __INLINE_CODE_5__, __INLINE_CODE_6__, __INLINE_CODE_7__, __INLINE_CODE_8__, __INLINE_CODE_9__, __INLINE_CODE_10__, __INLINE_CODE_11__, __INLINE_CODE_12__, __INLINE_CODE_13__, __INLINE_CODE_14__, __INLINE_CODE_15__, __INLINE_CODE_16__, __INLINE_CODE_17__, __INLINE_CODE_18__, __INLINE_CODE_19__, __INLINE_CODE_20__, __INLINE_CODE_21__, __INLINE_CODE_22__, __INLINE_CODE_23__, __INLINE_CODE_24__, __INLINE_CODE_25__, __INLINE_CODE_26__, __INLINE_CODE_27__, __INLINE_CODE_28__, __INLINE_CODE_29__), __INLINE_CODE_30__, or __INLINE_CODE_31__. Any other object shape, an unrecognized __INLINE_CODE_32__, a __INLINE_CODE_33__/__INLINE_CODE_34__ containing line terminators, or a string containing line terminators anywhere after a __INLINE_CODE_35__ throws a __INLINE_CODE_36__.
The output is POSIX shell (__INLINE_CODE_37__/__INLINE_CODE_38__) quoting. It is not valid for Windows __INLINE_CODE_39__ or PowerShell, whose rules differ and, for __INLINE_CODE_40__, are not solvable in the general case. On Windows, do not build a shell command string from this output; instead pass an argument array to a non-shell API such as __INLINE_CODE_41__ or __INLINE_CODE_42__ (or the __INLINE_CODE_43__ package), which does no shell parsing and needs no quoting.
Use the returned string verbatim as shell input. It is already a complete, escaped shell word (or words); do not wrap it in additional quotes or embed it in __INLINE_CODE_44__. Re-quoting the output (for example, placing it inside single quotes) turns its backslash escapes into literal characters and corrupts the value.
parse(cmd, env={})
Return an array of arguments from the quoted string __INLINE_CODE_45__.
Interpolate embedded bash-style __INLINE_CODE_46__ and __INLINE_CODE_47__ variables with the __INLINE_CODE_48__ object which like bash will replace undefined variables with __INLINE_CODE_49__.
By default an expanded variable is a single token even when unquoted. Pass __INLINE_CODE_50__ to split an unquoted expansion into multiple tokens the way a shell performs field splitting, using the default __INLINE_CODE_51__ (space, tab, newline). Pass a string to use its characters as the __INLINE_CODE_52__ instead (for example __INLINE_CODE_53__). A quoted expansion (__INLINE_CODE_54__) is never split.
Bash ANSI-C quoting (__INLINE_CODE_55__) is supported: escape sequences (such as __INLINE_CODE_56__, __INLINE_CODE_57__, __INLINE_CODE_58__, __INLINE_CODE_59__, __INLINE_CODE_60__, __INLINE_CODE_61__, __INLINE_CODE_62__, __INLINE_CODE_63__, __INLINE_CODE_64__, and __INLINE_CODE_65__) are decoded, an unrecognized escape keeps its backslash, and the contents are never word-split and never variable-expanded, so __INLINE_CODE_66__ inside __INLINE_CODE_67__ stays literal. As in bash, __INLINE_CODE_68__ is not special inside double or single quotes, and a NUL ends the string. Since the result is a JavaScript string, __INLINE_CODE_69__ and __INLINE_CODE_70__ produce the character with that code (U+0000 to U+00FF), not a raw byte.
Only simple __INLINE_CODE_71__ and __INLINE_CODE_72__ interpolation is supported. Bash parameter expansion beyond a plain variable name is not evaluated: forms such as array subscripts (__INLINE_CODE_73__), length (__INLINE_CODE_74__), and modifiers (__INLINE_CODE_75__, __INLINE_CODE_76__) are treated as an unknown variable and expand to __INLINE_CODE_77__, while arithmetic (__INLINE_CODE_78__) and command substitution (__INLINE_CODE_79__) are not interpreted. Whitespace inside __INLINE_CODE_80__ throws a __INLINE_CODE_81__ error.
__INLINE_CODE_82__ is usually an object but it can also be a function to perform lookups. When __INLINE_CODE_83__ returns a string, its result will be output just like __INLINE_CODE_84__ would. When __INLINE_CODE_85__ 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 __INLINE_CODE_86__ key set to the operator string. For example:
__CODE_BLOCK_17__parses as:
__CODE_BLOCK_18__The here-document operators (__INLINE_CODE_87__ and __INLINE_CODE_88__) are emitted like any other operator, followed by the delimiter word. The here-document body is not recognized: a newline is whitespace to __INLINE_CODE_89__, so the lines after the command are parsed as ordinary tokens, subject to quoting, comments, globs, and variable expansion.
install
With npm do:
__CODE_BLOCK_19__license
MIT
