Method: Unix::Exec#which
- Defined in:
- lib/beaker/host/unix/exec.rb
#which(command) ⇒ String
First path it finds for the command executable
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 |
# File 'lib/beaker/host/unix/exec.rb', line 439 def which(command) unless @which_command if execute('type -P true', :accept_all_exit_codes => true).empty? raise ArgumentError, "Could not find suitable 'which' command" if execute('which true', :accept_all_exit_codes => true).empty? @which_command = 'which' else @which_command = 'type -P' end end result = execute("#{@which_command} #{command}", :accept_all_exit_codes => true) return '' if result.empty? result end |