From 5dc6fbafa7cb0a3e959c1c2d4aa39a6d3359f62a Mon Sep 17 00:00:00 2001 From: NicolasGB Date: Fri, 19 Dec 2025 10:20:30 +1000 Subject: [PATCH] fix(runner): use sh -c wrapper for safe command execution --- lua/jj/cmd/init.lua | 5 ++--- lua/jj/core/runner.lua | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lua/jj/cmd/init.lua b/lua/jj/cmd/init.lua index 9ef86f4..5966601 100644 --- a/lua/jj/cmd/init.lua +++ b/lua/jj/cmd/init.lua @@ -25,11 +25,10 @@ local status_module = require("jj.cmd.status") --- @field close_on_edit? boolean Whether to close the log buffer when editing a change --- @class jj.cmd.log.keymaps ---- @field checkout? string|string[] Keymaps for the log command buffer, setting a keymap to nil will disable it ---- @field checkout_immutable? string|string[] +--- @field edit? string|string[] Keymaps for the log command buffer, setting a keymap to nil will disable it +--- @field edit_immutable? string|string[] --- @field describe? string|string[] --- @field diff? string|string[] ---- @field edit? string|string[] --- @field new? string|string[] --- @field new_after? string|string[] --- @field new_after_immutable? string|string[] diff --git a/lua/jj/core/runner.lua b/lua/jj/core/runner.lua index ad64130..a9d7f94 100644 --- a/lua/jj/core/runner.lua +++ b/lua/jj/core/runner.lua @@ -9,7 +9,7 @@ local M = {} --- @return string|nil output The command output, or nil if failed --- @return boolean success Whether the command succeeded function M.execute_command(cmd, error_prefix, input, silent) - local output = vim.fn.system(cmd, input) + local output = vim.fn.system({ "sh", "-c", cmd }, input) local success = vim.v.shell_error == 0 if not success then @@ -38,7 +38,7 @@ end function M.execute_command_async(cmd, on_success, error_prefix, input, silent) local output_lines = {} - local job_id = vim.fn.jobstart(cmd, { + local job_id = vim.fn.jobstart({ "sh", "-c", cmd }, { on_stdout = function(_, data) for _, line in ipairs(data) do if line ~= "" then