diff options
| author | Saikari <[email protected]> | 2026-02-02 09:27:39 +0300 |
|---|---|---|
| committer | Saikari <[email protected]> | 2026-02-02 09:27:39 +0300 |
| commit | e77b312440b1061261633fa41148275da74a75e5 (patch) | |
| tree | 4c2813171ecd54db08ffb071e1ab4f181c5a48ef /tests/modules/stdin/test.lua | |
| parent | 8a6b95da91feb273b1ad151fb2d0dbf57b3475b0 (diff) | |
refactor: simplify file handling in fix_ape_programfile function
Diffstat (limited to 'tests/modules/stdin/test.lua')
| -rw-r--r-- | tests/modules/stdin/test.lua | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/tests/modules/stdin/test.lua b/tests/modules/stdin/test.lua index fb62fa32c..6b1b4026b 100644 --- a/tests/modules/stdin/test.lua +++ b/tests/modules/stdin/test.lua @@ -10,19 +10,15 @@ end -- Fix /usr/bin/ape loader mode on Linux function fix_ape_programfile(xmake) if is_host("linux") and path.filename(xmake):find("ape", 1, true) and os.isfile("/proc/self/cmdline") then - local file = io.open("/proc/self/cmdline", "rb") - if file then - local content = io.readfile("/proc/self/cmdline") - file:close() - if content then - local args = {} - for arg in content:gmatch("[^\0]+") do - table.insert(args, arg) - end - if #args >= 2 and path.unix(args[1]) == xmake then - xmake = path.unix(args[2]) - xmake = resolve_path(xmake) - end + local content = io.readfile("/proc/self/cmdline") + if content then + local args = {} + for arg in content:gmatch("[^\0]+") do + table.insert(args, arg) + end + if #args >= 2 and path.unix(args[1]) == xmake then + xmake = path.unix(args[2]) + xmake = resolve_path(xmake) end end end @@ -48,7 +44,6 @@ function main(t) end local function test_shell(name, cmd, expect) - print("testing " .. name .. ": " .. cmd) local outfile = os.tmpfile() local errfile = os.tmpfile() local full_cmd = string.format('%s > "%s" 2> "%s"', cmd, outfile, errfile) |
