From adf042d7fcd696f1f29ad3e35f26ec52ce9d11e4 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Wed, 1 Mar 2017 22:56:28 -0800 Subject: Properly detect scala It seems that sometimes scala outputs a bogus line ahead out the version output. Use a match instead of a split to better handle this sort of thing. Signed-off-by: Tim Smith --- lib/ohai/plugins/scala.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/ohai/plugins/scala.rb b/lib/ohai/plugins/scala.rb index ee905a64..1f019bb2 100644 --- a/lib/ohai/plugins/scala.rb +++ b/lib/ohai/plugins/scala.rb @@ -23,9 +23,10 @@ Ohai.plugin(:Scala) do begin so = shell_out("scala -version") # Sample output: - # Scala code runner version 2.11.8 -- Copyright 2002-2016, LAMP/EPFL + # cat: /release: No such file or directory + # Scala code runner version 2.12.1 -- Copyright 2002-2016, LAMP/EPFL and Lightbend, Inc. if so.exitstatus == 0 - scala[:version] = so.stderr.split[4] + scala[:version] = so.stderr.match(/.*version (\S*)/)[1] end rescue Ohai::Exceptions::Exec Ohai::Log.debug('Plugin Scala: Could not shell_out "scala -version". Skipping data') -- cgit v1.2.1