Skip to content

Instantly share code, notes, and snippets.

@moto2002
Forked from Zbizu/getOS.lua
Created April 2, 2024 07:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moto2002/6a74eae4eacaf4895a9dff1b60b177f9 to your computer and use it in GitHub Desktop.
Save moto2002/6a74eae4eacaf4895a9dff1b60b177f9 to your computer and use it in GitHub Desktop.
operating system (OS) detection in Lua
function getOS()
-- ask LuaJIT first
if jit then
return jit.os
end
-- Unix, Linux variants
local fh,err = assert(io.popen("uname -o 2>/dev/null","r"))
if fh then
osname = fh:read()
end
return osname or "Windows"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment