Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env lua
- local first = true
- local function escape(input)
- input = input:gsub(" ", "\\ ")
- input = input:gsub("'", "\\'")
- input = input:gsub("\"", "\\\"")
- input = input:gsub("\n", "\\n")
- input = input:gsub("\r", "\\r")
- input = input:gsub("\b", "\\b")
- input = input:gsub("\t", "\\t")
- if first then
- first = false
- else
- input = " " .. input
- end
- return input
- end
- while true do
- local line = io.stdin:read("*l")
- if not line then return end
- io.stdout:write(escape(line))
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement