33: def find_cmd(*commands)
34: dirs_on_path = ENV['PATH'].to_s.split(File::PATH_SEPARATOR)
35: commands += commands.map{|cmd| "#{cmd}.exe"} if RUBY_PLATFORM =~ /win32/
36:
37: full_path_command = nil
38: found = commands.detect do |cmd|
39: dir = dirs_on_path.detect do |path|
40: full_path_command = File.join(path, cmd)
41: File.executable? full_path_command
42: end
43: end
44: found ? full_path_command : abort("Couldn't find database client: #{commands.join(', ')}. Check your $PATH and try again.")
45: end