Add pipe-bash example and make pipe-node a module
This commit is contained in:
parent
47ebfa202d
commit
5fa09b369e
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
( cat <&${R2PIPE_IN} ) &
|
||||
r2cmd() { echo "$1" >&${R2PIPE_OUT} ; }
|
||||
|
||||
r2cmd "x 64"
|
||||
r2cmd "pd 10"
|
|
@ -1,9 +1,9 @@
|
|||
#!/usr/bin/node
|
||||
// $ r2 -qc '#!pipe node ior2.js' -
|
||||
// $ r2 -qc '#!pipe node pipe-node.js' -
|
||||
|
||||
var isMain = process.argv[1] == __filename;
|
||||
|
||||
var fs = require ("fs");
|
||||
//var r2p = require ("r2pipe");
|
||||
|
||||
|
||||
function langPipe () {
|
||||
var IN = +process.env.R2PIPE_IN;
|
||||
|
@ -43,12 +43,15 @@ function langPipe () {
|
|||
return r2io;
|
||||
}
|
||||
|
||||
|
||||
var lp = langPipe ();
|
||||
lp.cmd ("pd 3", function (x) {
|
||||
console.log (x);
|
||||
lp.cmd ("px 64", function (y) {
|
||||
lp.repl ();
|
||||
// Example:
|
||||
if (isMain) {
|
||||
var lp = langPipe ();
|
||||
lp.cmd ("pd 3", function (x) {
|
||||
console.log (x);
|
||||
lp.cmd ("px 64", function (y) {
|
||||
lp.repl ();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
} else {
|
||||
module.exports = langPipe();
|
||||
}
|
||||
|
|
|
@ -47,7 +47,6 @@ static int lang_pipe_run(RLang *lang, const char *code, int len) {
|
|||
sleep (1);
|
||||
}
|
||||
#endif
|
||||
//write (input[1], "", 0); // EOF
|
||||
write (output[1], "", 1); // EOF
|
||||
close (input[0]);
|
||||
close (input[1]);
|
||||
|
|
Loading…
Reference in New Issue