Created
December 4, 2015 15:19
-
-
Save mpeterv/cbbd90ab99a8715da488 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env lua | |
| local remote_prog = [[ | |
| local name = [=[%s]=] | |
| local fh = assert(io.open(name)) | |
| local src = assert(fh:read("*a")) | |
| fh:close() | |
| local f = assert((loadstring or load)(src)) | |
| local activelines = assert(debug.getinfo(f, "L").activelines) | |
| local lines = {} | |
| for line in pairs(activelines) do table.insert(lines, line) end | |
| table.sort(lines) | |
| for _, line in ipairs(lines) do print(line) end | |
| ]] | |
| if not arg[1] or arg[1] == "-h" or arg[1] == "--help" then | |
| print("Pass a file name as the first argument.") | |
| print("Optionally, pass path to Lua interpreter as the second argument.") | |
| else | |
| os.execute((arg[2] or "lua") .. " -e '" .. remote_prog:format(arg[1]) .. "'") | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment