Skip to content

Commit

Permalink
fix: ssh adapter supports any system with /bin/sh (#161)
Browse files Browse the repository at this point in the history
This allows support of other *nix operating systems where bash is not
universally present.
  • Loading branch information
mahlonsmith authored Aug 24, 2023
1 parent e45aeeb commit ebcd720
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 2 additions & 3 deletions lua/oil/adapters/ssh/connection.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion tests/url_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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:///" },
Expand Down

0 comments on commit ebcd720

Please sign in to comment.