Skip to content

Commit

Permalink
fix: use sh -c to execute commands (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
HakonHarnes authored Apr 3, 2024
1 parent 61ece8b commit fc30500
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lua/img-clip/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local M = {}
M.verbose = true

---@param input_cmd string
---@param execute_directly boolean
---@param execute_directly? boolean
---@return string | nil output
---@return number exit_code
M.execute = function(input_cmd, execute_directly)
Expand All @@ -33,7 +33,7 @@ M.execute = function(input_cmd, execute_directly)

-- otherwise (linux, macos), execute the command directly
else
cmd = input_cmd
cmd = "sh -c " .. vim.fn.shellescape(input_cmd)
end

local output = vim.fn.system(cmd)
Expand Down
2 changes: 1 addition & 1 deletion tests/util_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe("util", function()
local command = "command"
local output, exit_code = util.execute(command)

assert.equal(output, command)
assert.equal(output, "sh -c 'command'")
assert.equal(exit_code, 0)
end)

Expand Down

0 comments on commit fc30500

Please sign in to comment.