require 'open3'
DOSROOT = 'z:'
def clean(output, stderr = false)
ends_with_newline = !!(output =~ /\n$/)
executable = ARGV[0].gsub(/\.exe\z/i, '')
output = output.gsub(/\r\n/, "\n")
results = output.split(/\n/).map do |line|
if line =~ /#{DOSROOT}\\/i
line.gsub!(/#{DOSROOT}([^:]*)/i) { |path|
path.gsub!(/^#{DOSROOT}/i, '')
path.gsub!(%r{\\}, '/')
path
}
end
line.gsub!(/(#{Regexp.escape executable})\.exe/i, '\1')
line
end
result_text = results.join("\n")
result_text += "\n" if ends_with_newline
result_text
end
def main
if ARGV.empty? || ARGV[0] =~ /^- (-?) (\?|help|h) $/x
puts "#{$0} <command-line>"
exit 0
end
if !STDIN.tty?
input = STDIN.read
else
input = ""
end
ENV['WINEDEBUG'] = 'err-all,warn-all,fixme-all,trace-all'
output, errormsg, status = Open3.capture3('wine', *ARGV, :stdin_data => input)
STDOUT.write clean(output)
STDERR.write clean(errormsg)
exit(status.exitstatus)
end
main()