Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

forward stdin into the current process

  • Loading branch information...
commit 0202e43a643178a9593b00ae8dd1fc33b9f3f586 1 parent c152053
@substack authored
Showing with 7 additions and 3 deletions.
  1. +7 −3 index.js
View
10 index.js
@@ -228,7 +228,7 @@ Bash.prototype.createStream = function () {
else if (c === 0x1b) {
mode = 'escape';
}
- else {
+ else if (!self.current) {
var before = line.slice(0, self._cursorX);
var after = line.slice(self._cursorX);
var middle = String.fromCharCode(c);
@@ -355,7 +355,7 @@ Bash.prototype.eval = function (line) {
if (!/\S+/.test(line)) {
return builtins.echo.call(self, [ '-n' ]);
}
- var output = resumer();
+ var input = through(), output = resumer();
if (Array.isArray(line)) line = line.join(' ');
var parts = shellQuote.parse(line, function (key) {
@@ -383,6 +383,8 @@ Bash.prototype.eval = function (line) {
}
}
+ var index = 0;
+
(function run (prevCode) {
self.env['?'] = prevCode;
@@ -513,10 +515,12 @@ Bash.prototype.eval = function (line) {
p.queue('No command ' + stringify(cmd) + ' found\n');
p.queue(null);
}
+
+ if (index++ === 0) input.pipe(p);
return p;
}
- return output;
+ return duplexer(input, output);
};
function copy (obj) {
Please sign in to comment.
Something went wrong with that request. Please try again.