aboutsummaryrefslogtreecommitdiffstats
path: root/lib/alaveteli_external_command.rb
diff options
context:
space:
mode:
authorSeb Bacon <seb.bacon@gmail.com>2012-01-18 08:47:35 +0000
committerSeb Bacon <seb.bacon@gmail.com>2012-01-18 08:47:35 +0000
commitebe06a0d61d9e5a65ef4d4301ed93d92aa35bd5c (patch)
tree3cf413323bd9a0b6f3dd26ccdf5941286882d141 /lib/alaveteli_external_command.rb
parentb50adc72e533a9c20aca03063a676f6af4d32b85 (diff)
parente190eebf7c4bd6a742706e60f2bf941f70d1a1e4 (diff)
Merge branch 'release/0.5' of github.com:sebbacon/alaveteli into release/0.5
Diffstat (limited to 'lib/alaveteli_external_command.rb')
-rw-r--r--lib/alaveteli_external_command.rb19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/alaveteli_external_command.rb b/lib/alaveteli_external_command.rb
index b967c89b5..b1d4f17d1 100644
--- a/lib/alaveteli_external_command.rb
+++ b/lib/alaveteli_external_command.rb
@@ -11,11 +11,26 @@ module AlaveteliExternalCommand
opts = args.pop
end
- xc = ExternalCommand.new(program_name, *args)
+ if program_name =~ %r(^/)
+ program_path = program_name
+ else
+ utility_search_path = MySociety::Config.get("UTILITY_SEARCH_PATH", ["/usr/bin", "/usr/local/bin"])
+ found = false
+ 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 #{utility_search_path.join(', ')}" if !found
+ end
+
+ xc = ExternalCommand.new(program_path, *args)
if opts.has_key? :append_to
xc.out = opts[:append_to]
end
- xc.run()
+ xc.run(opts[:stdin_string], opts[:env] || {})
if xc.status != 0
# Error
$stderr.puts("Error from #{program_name} #{args.join(' ')}:")