117: def self.exec(code, interpreter = nil)
118: Facter.warnonce "The interpreter parameter to 'exec' is deprecated and will be removed in a future version." if interpreter
119:
120: if expanded_code = expand_command(code)
121:
122: code = expanded_code
123: else
124:
125:
126: return nil unless Facter::Util::Config.is_windows?
127: return nil if absolute_path?(code)
128: end
129:
130: out = nil
131:
132: begin
133: out = %x{#{code}}.chomp
134: 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
135: rescue Errno::ENOENT => detail
136:
137: return nil
138: rescue => detail
139: $stderr.puts detail
140: return nil
141: end
142:
143: if out == ""
144: return nil
145: else
146: return out
147: end
148: end