From ebcd720a0987ed39f943c4a5d32b96d42e9cf695 Mon Sep 17 00:00:00 2001 From: "Mahlon E. Smith" Date: Thu, 24 Aug 2023 09:17:54 -0700 Subject: [PATCH] fix: ssh adapter supports any system with /bin/sh (#161) This allows support of other *nix operating systems where bash is not universally present. --- README.md | 2 +- lua/oil/adapters/ssh/connection.lua | 5 ++--- tests/url_spec.lua | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a1c72ed..c590fd5 100644 --- a/README.md +++ b/README.md @@ -267,7 +267,7 @@ nvim oil-ssh://[username@]hostname[:port]/[path] This may look familiar. In fact, this is the same url format that netrw uses. -Note that at the moment the ssh adapter does not support Windows machines, and it requires the server to have a `/bin/bash` binary as well as standard unix commands (`rm`, `mv`, `mkdir`, `chmod`, `cp`, `touch`, `ln`, `echo`). +Note that at the moment the ssh adapter does not support Windows machines, and it requires the server to have a `/bin/sh` binary as well as standard unix commands (`rm`, `mv`, `mkdir`, `chmod`, `cp`, `touch`, `ln`, `echo`). ## API diff --git a/lua/oil/adapters/ssh/connection.lua b/lua/oil/adapters/ssh/connection.lua index 6f6d05c..e2f5c11 100644 --- a/lua/oil/adapters/ssh/connection.lua +++ b/lua/oil/adapters/ssh/connection.lua @@ -83,12 +83,11 @@ end function SSHConnection.new(url) local command = SSHConnection.create_ssh_command(url) vim.list_extend(command, { - "/bin/bash", - "--norc", + "/bin/sh", "-c", -- HACK: For some reason in my testing if I just have "echo READY" it doesn't appear, but if I echo -- anything prior to that, it *will* appear. The first line gets swallowed. - "echo '_make_newline_'; echo '===READY==='; exec /bin/bash --norc", + "echo '_make_newline_'; echo '===READY==='; exec /bin/sh", }) local term_bufnr = vim.api.nvim_create_buf(false, true) local self = setmetatable({ diff --git a/tests/url_spec.lua b/tests/url_spec.lua index fbdde90..d9ecb30 100644 --- a/tests/url_spec.lua +++ b/tests/url_spec.lua @@ -4,7 +4,7 @@ describe("url", function() it("get_url_for_path", function() local cases = { { "", "oil://" .. util.addslash(vim.fn.getcwd()) }, - { "term://~/oil.nvim//52953:/bin/bash", "oil://" .. vim.loop.os_homedir() .. "/oil.nvim/" }, + { "term://~/oil.nvim//52953:/bin/sh", "oil://" .. vim.loop.os_homedir() .. "/oil.nvim/" }, { "/foo/bar.txt", "oil:///foo/", "bar.txt" }, { "oil:///foo/bar.txt", "oil:///foo/", "bar.txt" }, { "oil:///", "oil:///" },