def which(prog, path = ENV['PATH'])
      path.split(File::PATH_SEPARATOR).each do |dir|
        file = File.join(dir, prog)
        return file if File.executable?(file) && !File.directory?(file)
      end

      nil
    end
def which(prog, path = ENV['PATH'])
      path.split(File::PATH_SEPARATOR).each do |dir|
        file = File.join(dir, prog)
        return file if File.executable?(file) && !File.directory?(file)
      end

      nil
    end
Looks for the first occurrence of program within path.

 @param [String] cmd
   The name of the command to find.

 @param [String] path
   The path to search for the command.

 @return [String, NilClass]

 @api public