From 7c1ebd1d339ac73fb3b4f7c74b8fb9587d4244c7 Mon Sep 17 00:00:00 2001 From: Dan Carley Date: Mon, 4 Mar 2013 08:08:51 +0000 Subject: [PATCH] (GH-139) Throw away STDERR from dpkg-query in Fact Newer versions of dpkg-query, as of Ubuntu 12.10, will make noise on STDERR if the queried package isn't currently installed. Facter's `exec()` outputs this without giving us a chance to catch it. Pipe STDERR to `/dev/null` so that it's not seen by the end-user. STDOUT will still be `nil` if the package isn't installed. It doesn't seem reasonable to spec test for this without reaching deep into Facter, so I'm not going to. --- lib/facter/iptables_persistent_version.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/facter/iptables_persistent_version.rb b/lib/facter/iptables_persistent_version.rb index 2bae97a..80bf9de 100644 --- a/lib/facter/iptables_persistent_version.rb +++ b/lib/facter/iptables_persistent_version.rb @@ -1,7 +1,9 @@ Facter.add(:iptables_persistent_version) do confine :operatingsystem => %w{Debian Ubuntu} setcode do - cmd = "dpkg-query -Wf '${Version}' iptables-persistent" + # Throw away STDERR because dpkg >= 1.16.7 will make some noise if the + # package isn't currently installed. + cmd = "dpkg-query -Wf '${Version}' iptables-persistent 2>/dev/null" version = Facter::Util::Resolution.exec(cmd) if version.nil? or !version.match(/\d+\.\d+/) -- 2.45.2