diff --git a/index.js b/index.js index 0ceaf189f..a3737fe7b 100644 --- a/index.js +++ b/index.js @@ -405,14 +405,15 @@ Command.prototype.executeSubCommand = function(argv, args, unknown) { // check for ./ first var local = path.join(dir, bin); - if (exists(local)) bin = local; // run it args = args.slice(1); - var proc = spawn(bin, args, { stdio: 'inherit', customFds: [0, 1, 2] }); - proc.on('exit', function(code){ - if (code == 127) { - console.error('\n %s(1) does not exist\n', bin); + var proc = spawn(local, args, { stdio: 'inherit', customFds: [0, 1, 2] }); + proc.on('error', function(err){ + if (err.code == "ENOENT") { + console.error('\n %s(1) does not exist, try --help\n', bin); + } else if (err.code == "EACCES") { + console.error('\n %s(1) not executable. try chmod or run with root\n', bin); } }); };