function shell() { process.stdin.pause();
require('tty').setRawMode(false);
var ch = require('child_process').spawn('/bin/bash', [], {
customFds: [0, 1, 2]}); ch.on('exit',
function(){require('tty').setRawMode(true); process.stdin.resume()});
}
shell();
If you do not use readline in your app, you can remove the setRawMode() calls.
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+un...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>
All working now, here's the JS code:
8<--------------------
var shell, spawn, tty;
spawn = require('child_process').spawn;
tty = require('tty');
shell = function(cmd, opts, callback) {
var p;
process.stdin.pause();
tty.setRawMode(false);
p = spawn(cmd, opts, {
customFds: [0, 1, 2]
});
return p.on('exit', function() {
tty.setRawMode(true);
process.stdin.resume();
return callback();
});
};
shell('less', ['Cakefile'], function() {
return process.exit();
});
8<--------------------
Compiled from this CoffeeScript:
8<--------------------
{spawn} = require 'child_process'
tty = require 'tty'
shell = (cmd, opts, callback) ->
process.stdin.pause()
tty.setRawMode false
p = spawn cmd, opts, customFds: [0, 1, 2]
p.on 'exit', ->
tty.setRawMode true
process.stdin.resume()
callback()
shell 'less', ['Cakefile'], -> process.exit()
8<--------------------
Cheers, Stuart