fix: ssh adapter supports any system with /bin/sh (#161)

This allows support of other *nix operating systems where bash is not
universally present.
This commit is contained in:
Mahlon E. Smith 2023-08-24 09:17:54 -07:00 committed by GitHub
parent e45aeebc2b
commit ebcd720a09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 5 deletions

View file

@ -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

View file

@ -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({

View file

@ -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:///" },