Sha256: 5bab99b7d380158f92f2ff93a1b88bae496bb68e93ec8f4b1d339a363ca0fd67

Contents?: true

Size: 615 Bytes

Versions: 1

Compression:

Stored size: 615 Bytes

Contents

# encoding: utf-8

require 'open3'

module Cliver
  module Which
    # Posix implementation of Which
    # Required and mixed into Cliver::Which in posix environments
    module Posix
      # @param executable [String]
      # @return [nil,String] - path to found executable
      def which(executable)
        # command -v is the POSIX-specified implementation behind which.
        # http://pubs.opengroup.org/onlinepubs/009695299/utilities/command.html
        which, status = Open3.capture2e('command', '-v', executable)
        return nil unless status.success?
        which.chomp
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cliver-0.1.1 lib/cliver/which/posix.rb