Skip to content

Commit fc30500

Browse files
authored
fix: use sh -c to execute commands (#65)
1 parent 61ece8b commit fc30500

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lua/img-clip/util.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ local M = {}
66
M.verbose = true
77

88
---@param input_cmd string
9-
---@param execute_directly boolean
9+
---@param execute_directly? boolean
1010
---@return string | nil output
1111
---@return number exit_code
1212
M.execute = function(input_cmd, execute_directly)
@@ -33,7 +33,7 @@ M.execute = function(input_cmd, execute_directly)
3333

3434
-- otherwise (linux, macos), execute the command directly
3535
else
36-
cmd = input_cmd
36+
cmd = "sh -c " .. vim.fn.shellescape(input_cmd)
3737
end
3838

3939
local output = vim.fn.system(cmd)

tests/util_spec.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe("util", function()
2525
local command = "command"
2626
local output, exit_code = util.execute(command)
2727

28-
assert.equal(output, command)
28+
assert.equal(output, "sh -c 'command'")
2929
assert.equal(exit_code, 0)
3030
end)
3131

0 commit comments

Comments
 (0)