diff --git a/example/op.js b/example/op.js new file mode 100644 index 0000000..d8d9064 --- /dev/null +++ b/example/op.js @@ -0,0 +1,3 @@ +var parse = require('../').parse; +var xs = parse('beep || boop > /byte'); +console.dir(xs); diff --git a/readme.markdown b/readme.markdown index 2e21a5a..48b6bfd 100644 --- a/readme.markdown +++ b/readme.markdown @@ -48,6 +48,20 @@ output [ 'beep', '--boop=/home/robot' ] ``` +## parsing shell operators + +``` js +var parse = require('shell-quote').parse; +var xs = parse('beep || boop > /byte'); +console.dir(xs); +``` + +output: + +``` +[ 'beep', { op: '||' }, 'boop', { op: '>' }, '/byte' ] +``` + # methods ``` js @@ -67,6 +81,19 @@ 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 `""`. +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](http://npmjs.org) do: