Skip to content

Commit

Permalink
fix: Use uname to check for Linux
Browse files Browse the repository at this point in the history
In build environments like Fedora's mockbuild, there is no OSTYPE
environment variable set. Use a more secure method to detect Linux.
  • Loading branch information
cryptomilk committed Jan 15, 2024
1 parent 77f1bd3 commit 463c5d5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@ if _G.jit and _G.jit.os then
else
-- Normal lua will only have \ for path separator on windows.
utils.isWindows = package.config:find("\\") and true or false
utils.isLinux = false

if not utils.isWindows then
local _os = os.getenv('RUNNER_OS') or os.getenv('OSTYPE')
if (_os and _os:lower():match('linux')) then
utils.isLinux = true
-- TODO Use uv.os_uname() when the minimum required libuv provides it
local popen_handle = io.popen('uname -s')
if popen_handle then
local uname_os = assert(popen_handle:read('*a'))
popen_handle:close()
utils.isLinux = uname_os:lower() == 'linux'
end
end
end
Expand Down

0 comments on commit 463c5d5

Please sign in to comment.