[Pkg-javascript-commits] [node-shell-quote] 54/137: document ops, op example

Bastien Roucariès rouca at moszumanska.debian.org
Fri Aug 25 19:19:39 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-shell-quote.

commit a6381e612361148a8433c6ec4891aabc4649cb40
Author: James Halliday <mail at substack.net>
Date:   Mon May 13 03:25:57 2013 -0700

    document ops, op example
---
 example/op.js   |  3 +++
 readme.markdown | 27 +++++++++++++++++++++++++++
 2 files changed, 30 insertions(+)

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:

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-shell-quote.git



More information about the Pkg-javascript-commits mailing list