def self.exec(code, interpreter = nil)
Facter.warnonce "The interpreter parameter to 'exec' is deprecated and will be removed in a future version." if interpreter
if expanded_code = expand_command(code)
code = expanded_code
else
return nil unless Facter::Util::Config.is_windows?
return nil if absolute_path?(code)
end
out = nil
begin
out = %x{#{code}}.chomp
Facter.warnonce 'Using Facter::Util::Resolution.exec with a shell built-in is deprecated. Most built-ins can be replaced with native ruby commands. If you really have to run a built-in, pass "cmd /c your_builtin" as a command' unless expanded_code
rescue Errno::ENOENT => detail
return nil
rescue => detail
$stderr.puts detail
return nil
end
if out == ""
return nil
else
return out
end
end