lambdalisue/vim-fern-ssh

[bug] wrong cmd args

Open

#2 opened on Mar 15, 2022

View on GitHub
 (15 comments) (0 reactions) (0 assignees)Vim Script (0 forks)github user discovery
help wanted

Repository metrics

Stars
 (26 stars)
PR merge metrics
 (PR metrics pending)

Description

❯ vi ssh://wzy@localhost:22//home/wzy/
[fern] ERROR: {'stderr': [''], 'args': ['ssh', '-T', '-x', 'wzy@localhost:22', 'cat /home/wzy/'], 'exitval': 143, 'stdout': ['']}
❯ ssh -T -x wzy@localhost:22 cat /home/wzy/
ssh: Could not resolve hostname localhost:22: Name or service not known
❯ ssh -T -x ssh://wzy@localhost:22 cat /home/wzy
cat: /home/wzy: Is a directory
❯ ssh -T -x ssh://wzy@localhost:22 ls /home/wzy/
Applications
Desktop
Documents
Downloads
...

Should add ssh:// prefix, and judge the file type (directory or normal file) then use ls or cat

index e126d13..6b52c24 100644
--- a/autoload/fern_ssh/connection.vim
+++ b/autoload/fern_ssh/connection.vim
@@ -11,7 +11,7 @@ endfunction
 
 function! s:connection_start(args, ...) abort dict
   let options = copy(a:0 ? a:1 : {})
-  let args = ['ssh', '-T', '-x', self.host, s:cmdline(a:args)]
+  let args = ['ssh', '-T', '-x', 'ssh://' . self.host, s:cmdline(a:args)]
   call fern#logger#debug(args)
   return s:Process.start(args, options)
 endfunction

it can fix the prefix bug, for ls and cat, I think a command like test -d $(realpath /home/wzy/Desktop/h) && ls /home/wzy/Desktop/h || cat /home/wzy/Desktop/h to judge filetype may be useful, but directory is different from normal file -- vi should get a files list containing by a directory, then use fern to handle it.

A weird behaviour is Fern /home/wzy/Desktop in vi can work normally -- use Fern to open the directory, Fern /home/wzy/LICENSE cannot work, fern will return a blank buffer only containing a line LICENSE/. Looks like fern think LICENSE is a directory not a normal file.

Contributor guide