diff options
| author | Saikari <[email protected]> | 2026-02-02 03:33:23 +0300 |
|---|---|---|
| committer | Saikari <[email protected]> | 2026-02-02 03:33:23 +0300 |
| commit | f3b8a1296313ee90a3451257f0f2cfa2964795b0 (patch) | |
| tree | 0778e138ae3abdf55f2684d49a063e354db0faf1 /tests/modules/stdin/test.lua | |
| parent | 42fb29e925668f87329ac8ea42ec2af0f6e37634 (diff) | |
refactor: enhance Linux APE loader mode handling and update MacOS stdin command format
Diffstat (limited to 'tests/modules/stdin/test.lua')
| -rw-r--r-- | tests/modules/stdin/test.lua | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/tests/modules/stdin/test.lua b/tests/modules/stdin/test.lua index 665857595..f54bb97c7 100644 --- a/tests/modules/stdin/test.lua +++ b/tests/modules/stdin/test.lua @@ -4,6 +4,27 @@ function main(t) xmake = xmake:gsub("/", "\\") end + -- Fix /usr/bin/ape loader mode on Linux + if os.host() == "linux" and path.filename(xmake) == "ape" and os.isfile("/proc/self/cmdline") then + local file = io.open("/proc/self/cmdline", "rb") + if file then + local content = file:read("*a") + 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]) + if not path.is_absolute(xmake) then + xmake = path.absolute(xmake) + end + end + end + end + end + -- APE/Cosmocc workaround: force xmake name to avoid APE loader mode issues (e.g. ape-x86_64.elf) local function setup_xmake_alias(xmake) if path.filename(xmake):find("ape-", 1, true) then @@ -22,11 +43,11 @@ function main(t) local is_ape = path.filename(xmake):find("ape-", 1, true) -- Fix pwsh and cosmocc "err: ape error: l: not found (maybe chmod +x or ./ needed)" for Linux - xmake = setup_xmake_alias(xmake) + --xmake = setup_xmake_alias(xmake) local run_stdin = string.format('env "%s" l --stdin', xmake) -- Fix pwsh and cosmocc "exec format error" for MacOS - if is_ape and os.host() ~= "windows" then + if is_ape and (os.host() == "macosx" or os.host() == "linux") then run_stdin = string.format("sh -c ' \\\"%s\\\" l --stdin '", xmake) end |
