-
-
Save moto2002/6a74eae4eacaf4895a9dff1b60b177f9 to your computer and use it in GitHub Desktop.
operating system (OS) detection in Lua
This file contains 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 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