local inherited, unset, passed, ungranted = arg[1], arg[2], arg[3], arg[4]
local function first_line(message)
return string.match(message, "^[^\n]*") or message
end
local path = airsstack.env.get(inherited)
print(inherited .. ": granted, set, " .. tostring(#path > 0 and "non-empty" or "empty"))
print(unset .. ": granted, unset -> " .. tostring(airsstack.env.get(unset)))
local ok, err = pcall(airsstack.env.get, ungranted)
assert(not ok, "an ungranted name must raise")
print(ungranted .. ": " .. first_line(tostring(err)))
airsstack.env.set(passed, "from-lua")
print(passed .. ": set in the overlay")
local names = {}
for name in pairs(airsstack.env.all()) do
names[#names + 1] = name
end
table.sort(names)
print("env.all() sees: " .. table.concat(names, ", "))
local echo = airsstack.proc.run({ "sh", "-c", "printf %s \"$" .. passed .. "\"" })
print("child reported: " .. echo.stdout .. " (status " .. echo.status .. ")")
local failed = airsstack.proc.run({ "sh", "-c", "exit 3" })
print("deliberate failure: status " .. failed.status .. ", raised nothing")
print("which sh resolved: " .. tostring(airsstack.proc.which("sh") ~= nil))
local ran, run_err = pcall(airsstack.proc.run, { "curl", "https://example.com" })
assert(not ran, "an ungranted executable must raise")
print("curl: " .. first_line(tostring(run_err)))