index.js
function bash(pattern, options, cb) {
  if (!isGlob(pattern)) {
    return nonGlob(pattern, options, cb);
  }

  if (typeof options === 'function') {
    cb = options;
    options = undefined;
  }

  var opts = extend({cwd: process.cwd()}, options);

  fs.stat(opts.cwd, function(err, stat) {
    if (err) {
      cb(handleError(err, pattern, opts));
      return;
    }

    if (!stat.isDirectory()) {
      cb(new Error('cwd is not a directory: ' + opts.cwd));
      return;
    }

    var cp = spawn(bashPath, cmd(pattern, options), options);
    var buf = new Buffer(0);

    cp.stdout.on('data', function(data) {
      emitMatches(data.toString(), pattern, options);
      buf = Buffer.concat([buf, data]);
    });

    cp.stderr.on('data', function(data) {
      cb(handleError(data.toString(), pattern, options));
    });

    cp.on('close', function(code) {
      cb(code, getFiles(buf.toString(), pattern, options));
    });
  });
}
function bash(pattern, options, cb) {
  if (!isGlob(pattern)) {
    return nonGlob(pattern, options, cb);
  }

  if (typeof options === 'function') {
    cb = options;
    options = undefined;
  }

  var opts = extend({cwd: process.cwd()}, options);

  fs.stat(opts.cwd, function(err, stat) {
    if (err) {
      cb(handleError(err, pattern, opts));
      return;
    }

    if (!stat.isDirectory()) {
      cb(new Error('cwd is not a directory: ' + opts.cwd));
      return;
    }

    var cp = spawn(bashPath, cmd(pattern, options), options);
    var buf = new Buffer(0);

    cp.stdout.on('data', function(data) {
      emitMatches(data.toString(), pattern, options);
      buf = Buffer.concat([buf, data]);
    });

    cp.stderr.on('data', function(data) {
      cb(handleError(data.toString(), pattern, options));
    });

    cp.on('close', function(code) {
      cb(code, getFiles(buf.toString(), pattern, options));
    });
  });
}
function bash ( pattern , options , cb ) { if ( ! isGlob ( pattern ) ) { return nonGlob ( pattern , options , cb ) ; } if ( typeof options === 'function' ) { cb = options ; options = undefined ; } var opts = extend ( { cwd : process . cwd ( ) } , options ) ; fs . stat ( opts . cwd , function ( err , stat ) { if ( err ) { cb ( handleError ( err , pattern , opts ) ) ; return ; } if ( ! stat . isDirectory ( ) ) { cb ( new Error ( 'cwd is not a directory: ' + opts . cwd ) ) ; return ; } var cp = spawn ( bashPath , cmd ( pattern , options ) , options ) ; var buf = new Buffer ( 0 ) ; cp . stdout . on ( 'data' , function ( data ) { emitMatches ( data . toString ( ) , pattern , options ) ; buf = Buffer . concat ( [ buf , data ] ) ; } ) ; cp . stderr . on ( 'data' , function ( data ) { cb ( handleError ( data . toString ( ) , pattern , options ) ) ; } ) ; cp . on ( 'close' , function ( code ) { cb ( code , getFiles ( buf . toString ( ) , pattern , options ) ) ; } ) ; } ) ; }
Base bash function
Base bash function