def self.expand_command(command)
if match = /^"(.+?)"(?:\s+(.*))?/.match(command)
exe, arguments = match.captures
exe = which(exe) and [ "\"#{exe}\"", arguments ].compact.join(" ")
elsif match = /^'(.+?)'(?:\s+(.*))?/.match(command) and not Facter::Util::Config.is_windows?
exe, arguments = match.captures
exe = which(exe) and [ "'#{exe}'", arguments ].compact.join(" ")
else
exe, arguments = command.split(/ /,2)
if exe = which(exe)
exe = "\"#{exe}\"" if exe =~ /\s/ and Facter::Util::Config.is_windows?
exe = "'#{exe}'" if exe =~ /\s/ and not Facter::Util::Config.is_windows?
[ exe, arguments ].compact.join(" ")
end
end
end