92: def self.expand_command(command)
93: if match = /^"(.+?)"(?:\s+(.*))?/.match(command)
94: exe, arguments = match.captures
95: exe = which(exe) and [ "\"#{exe}\"", arguments ].compact.join(" ")
96: elsif match = /^'(.+?)'(?:\s+(.*))?/.match(command) and not Facter::Util::Config.is_windows?
97: exe, arguments = match.captures
98: exe = which(exe) and [ "'#{exe}'", arguments ].compact.join(" ")
99: else
100: exe, arguments = command.split(/ /,2)
101: if exe = which(exe)
102:
103:
104: exe = "\"#{exe}\"" if exe =~ /\s/ and Facter::Util::Config.is_windows?
105: exe = "'#{exe}'" if exe =~ /\s/ and not Facter::Util::Config.is_windows?
106: [ exe, arguments ].compact.join(" ")
107: end
108: end
109: end