From 03dac753daadb79e1723406fad5a027324827007 Mon Sep 17 00:00:00 2001 From: Franz Pletz Date: Thu, 10 Dec 2015 17:36:50 +0100 Subject: [PATCH] phpversion fact: Don't output errors of php is not found Fixes #134. --- lib/facter/phpversion.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/facter/phpversion.rb b/lib/facter/phpversion.rb index 6f4b6ece..1460adb0 100644 --- a/lib/facter/phpversion.rb +++ b/lib/facter/phpversion.rb @@ -1,7 +1,10 @@ Facter.add(:phpversion) do setcode do - Facter::Util::Resolution.exec('php -v'). - split("\n").first.split(' '). - select { |x| x =~ /^(?:(\d+)\.)(?:(\d+)\.)?(\*|\d+)/ }.first + output = Facter::Util::Resolution.exec('php -v') + + unless output.nil? + output.split("\n").first.split(' '). + select { |x| x =~ /^(?:(\d+)\.)(?:(\d+)\.)?(\*|\d+)/ }.first + end end end