eol.lua 563 B

12345678910111213
  1. -----------------------------------------------------------------------------
  2. -- Little program to adjust end of line markers.
  3. -- LuaSocket sample files
  4. -- Author: Diego Nehab
  5. -----------------------------------------------------------------------------
  6. local mime = require("mime")
  7. local ltn12 = require("ltn12")
  8. local marker = '\n'
  9. if arg and arg[1] == '-d' then marker = '\r\n' end
  10. local filter = mime.normalize(marker)
  11. local source = ltn12.source.chain(ltn12.source.file(io.stdin), filter)
  12. local sink = ltn12.sink.file(io.stdout)
  13. ltn12.pump.all(source, sink)