Method: Chef::Sugar::Shell#which
- Defined in:
- lib/chef/sugar/shell.rb
#which(cmd) ⇒ String?
Finds a command in $PATH
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/chef/sugar/shell.rb', line 32 def which(cmd) paths = ENV['PATH'].split(::File::PATH_SEPARATOR) + %w(/bin /usr/bin /sbin /usr/sbin) paths.each do |path| possible = File.join(path, cmd) return possible if File.executable?(possible) end nil end |