aboutsummaryrefslogtreecommitdiffstats
path: root/lib/alaveteli_external_command.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/alaveteli_external_command.rb')
-rw-r--r--lib/alaveteli_external_command.rb27
1 files changed, 14 insertions, 13 deletions
diff --git a/lib/alaveteli_external_command.rb b/lib/alaveteli_external_command.rb
index 086a461c8..79711328c 100644
--- a/lib/alaveteli_external_command.rb
+++ b/lib/alaveteli_external_command.rb
@@ -18,19 +18,7 @@ module AlaveteliExternalCommand
opts = args.pop
end
- if program_name =~ %r(^/)
- program_path = program_name
- else
- found = false
- AlaveteliConfiguration::utility_search_path.each do |d|
- program_path = File.join(d, program_name)
- if File.file? program_path and File.executable? program_path
- found = true
- break
- end
- end
- raise "Could not find #{program_name} in any of #{AlaveteliConfiguration::utility_search_path.join(', ')}" if !found
- end
+ program_path = find_program(program_name)
xc = ExternalCommand.new(program_path, *args)
if opts.has_key? :append_to
@@ -61,5 +49,18 @@ module AlaveteliExternalCommand
end
end
end
+
+ def find_program(program_name)
+ if program_name =~ %r(^/)
+ return program_name
+ else
+ search_path = AlaveteliConfiguration::utility_search_path
+ search_path.each do |d|
+ program_path = File.join(d, program_name)
+ return program_name if File.file? program_path and File.executable? program_path
+ end
+ raise "Could not find #{program_name} in any of #{search_path.join(', ')}"
+ end
+ end
end
end