Skip to content

Commit

Permalink
Fixed platform mismatch in shell API
Browse files Browse the repository at this point in the history
  • Loading branch information
curlpipe committed Oct 31, 2024
1 parent 158052d commit d29cd25
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/plugin/bootstrap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,6 @@ function shell:spawn(cmd)
-- Spawns a command (silently), and have it run in the background
-- Returns PID so process can be killed later
if self.is_windows then
local command = cmd .. " > /dev/null 2>&1 & echo $!"
local pid = shell:output(command)
pid = pid:gsub("%s+", "")
pid = pid:gsub("\\n", "")
pid = pid:gsub("\\t", "")
return pid
else
-- Write the command to a batch file
local temp = os.tmpname() .. ".bat"
local handle = io.open(temp, "w")
Expand All @@ -149,12 +142,23 @@ function shell:spawn(cmd)
end
-- Return the PID
return lastPID
else
local command = cmd .. " > /dev/null 2>&1 & echo $!"
local pid = shell:output(command)
pid = pid:gsub("%s+", "")
pid = pid:gsub("\\n", "")
pid = pid:gsub("\\t", "")
return pid
end
end

function shell:kill(pid)
if pid ~= nil then
shell:run("kill " .. tostring(pid))
if self.is_windows then
shell:run("kill " .. tostring(pid))
else
shell:run("taskkill /PID " .. tostring(pid) .. " /F")
end
end
end

Expand Down

0 comments on commit d29cd25

Please sign in to comment.