Created
January 28, 2026 17:25
-
-
Save chip/79c40b0491e715054bbe7cdaeb509af0 to your computer and use it in GitHub Desktop.
Lua get pwd, open file, read data
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
| function open_file(filename) | |
| local dir = io.popen("pwd"):read() | |
| local path = dir .. filename | |
| local file = io.open(path, "rb") | |
| if not file then return nil end | |
| local data = file:read("*ab") | |
| return data | |
| end | |
| print(open_file("/lua/tests/fixtures/MARKDOWN.lua")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment