From ce8739163a6e0d06fd2a3b13395d6686e1797fa4 Mon Sep 17 00:00:00 2001 From: TakodaS Date: Thu, 11 Jul 2024 15:27:33 +0100 Subject: [PATCH] Fix error testing remote with echo "echo 'Hello'" is a nasty nested string that causes undefined behavior with vim.fn.shellescape. Much better to use "pwd"! Oh, and I added an extra line of debug information to get the raw ssh command executed. --- lua/remote-nvim/providers/executor.lua | 3 +++ lua/remote-nvim/providers/provider.lua | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lua/remote-nvim/providers/executor.lua b/lua/remote-nvim/providers/executor.lua index d73336eb..8b9e8c2b 100644 --- a/lua/remote-nvim/providers/executor.lua +++ b/lua/remote-nvim/providers/executor.lua @@ -16,6 +16,7 @@ local Executor = require("remote-nvim.middleclass")("Executor") ---@field exit_cb function? On exit callback ---@field compression remote-nvim.provider.Executor.JobOpts.CompressionOpts? Compression options; for upload and download +local utils = require("remote-nvim.utils") ---Initialize executor instance ---@param host string Host name ---@param conn_opts? string Connection options (passed when connecting) @@ -23,6 +24,7 @@ function Executor:init(host, conn_opts) self.host = host self.conn_opts = conn_opts or "" + self.logger = utils.get_logger() self._job_id = nil self._job_exit_code = nil self._job_stdout = {} @@ -71,6 +73,7 @@ end ---@param command string Command which should be started as a job ---@param job_opts remote-nvim.provider.Executor.JobOpts function Executor:run_executor_job(command, job_opts) + self.logger.fmt_debug("Executor running command %s with options %s", command, job_opts) local co = coroutine.running() job_opts = job_opts or {} diff --git a/lua/remote-nvim/providers/provider.lua b/lua/remote-nvim/providers/provider.lua index 0deb949b..cd4b9887 100644 --- a/lua/remote-nvim/providers/provider.lua +++ b/lua/remote-nvim/providers/provider.lua @@ -139,7 +139,7 @@ end function Provider:_setup_workspace_variables() if vim.tbl_isempty(self._config_provider:get_workspace_config(self.unique_host_id)) then self.logger.debug("Did not find any existing configuration. Creating one now..") - self:run_command("echo 'Hello'", "Testing remote connection") + self:run_command("pwd", "Testing remote connection") self._config_provider:add_workspace_config(self.unique_host_id, { provider = self.provider_type, host = self.host,