lib/beaker/host/unix/exec.rb
#First path it finds for the command executable
#@param [String] command The command executable to search for
#
# @return [String] Path to the searched executable or empty string if not found
#
#@example
#  host.which('ruby')
First path it finds for the command executable
First path it finds for the command executable
def which(command)
    unless @which_command
      if execute('type -P true', :accept_all_exit_codes => true).empty?
        if execute('which true', :accept_all_exit_codes => true).empty?
          raise ArgumentError, "Could not find suitable 'which' command"
        else
          @which_command = 'which'
        end
      else
        @which_command = 'type -P'
      end
    end
    result = execute("#{@which_command} #{command}", :accept_all_exit_codes => true)
    return '' if result.empty?
    result
  end
def which ( command ) unless @which_command if execute ( 'type -P true' , :accept_all_exit_codes => true ) . empty? if execute ( 'which true' , :accept_all_exit_codes => true ) . empty? raise ArgumentError , "Could not find suitable 'which' command" else @which_command = 'which' end else @which_command = 'type -P' end end result = execute ( "#{@which_command} #{command}" , :accept_all_exit_codes => true ) return '' if result . empty? result end
First path it finds for the command executable
First path it finds for the command executable
command
command The command executable to search for @return  Path to the searched executable or empty string if not found
command The command executable to search for @return Path to the searched executable or empty string if not found
example
None