aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorXu Cheng2015-01-24 20:58:02 +0800
committerMike McQuaid2015-01-25 10:05:56 +0000
commit8fc3c4c8e99a52ed85fc60f670760136d14c6547 (patch)
tree6c589682792b0fbe3894e8ac3f955c6db130c2ab /Library
parentc60454a72f2e0bdbf5a3192bd51439e2de2183d2 (diff)
downloadbrew-8fc3c4c8e99a52ed85fc60f670760136d14c6547.tar.bz2
brew-config: check whether java exists in PATH
For OS X, we will call `/usr/libexec/java_home` to exam whehter java is installed. Also rename the method to follow the same naming pattern of other similar methods. Closes Homebrew/homebrew#36187. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cmd/config.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/Library/Homebrew/cmd/config.rb b/Library/Homebrew/cmd/config.rb
index 69914dec0..f5f56d1a6 100644
--- a/Library/Homebrew/cmd/config.rb
+++ b/Library/Homebrew/cmd/config.rb
@@ -119,9 +119,13 @@ module Homebrew
s
end
- def java_version
- java = `java -version 2>&1`.lines.first.chomp
- java =~ /java version "(.+?)"/ ? $1 : java
+ def describe_java
+ if which("java").nil? || !quiet_system("/usr/libexec/java_home --failfast")
+ "N/A"
+ else
+ java = `java -version 2>&1`.lines.first.chomp
+ java =~ /java version "(.+?)"/ ? $1 : java
+ end
end
def dump_verbose_config(f=$stdout)
@@ -145,6 +149,6 @@ module Homebrew
f.puts "Perl: #{describe_perl}"
f.puts "Python: #{describe_python}"
f.puts "Ruby: #{describe_ruby}"
- f.puts "Java: #{java_version}"
+ f.puts "Java: #{describe_java}"
end
end