diff options
author | Robin Houston <robin.houston@gmail.com> | 2012-01-17 21:43:40 +0000 |
---|---|---|
committer | Robin Houston <robin.houston@gmail.com> | 2012-01-17 21:43:40 +0000 |
commit | e190eebf7c4bd6a742706e60f2bf941f70d1a1e4 (patch) | |
tree | 0735d4a36215df79a4c8ec854df3793b5f9cb310 /lib | |
parent | 3affd6ab3d29bf2e86c9d4b00733499d060af20c (diff) | |
parent | 41d544631dcb6748ea792f1d8019b5e301056d18 (diff) |
Merge branch 'wdtk' into release/0.5
Diffstat (limited to 'lib')
-rw-r--r-- | lib/alaveteli_external_command.rb | 19 |
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(' ')}:") |