Closed rpdelaney closed 2 years ago
Hi, I suppose this line is the error? https://github.com/chrisbra/Recover.vim/blob/a6f8d9e6086e611daf55f3fe05c06e7aaaf46f35/autoload/recover.vim#L45
Looks like it. Here's the output on my macbook using the built-in BSD stat vs GNU stat (which is gstat
when installed with homebrew):
$ /usr/bin/stat --printf="%U\n%Y\n" pyproject.toml
/usr/bin/stat: illegal option -- -
usage: stat [-FLnq] [-f format | -l | -r | -s | -x] [-t timefmt] [file ...]
$ gstat --printf="%U\n%Y\n" pyproject.toml
"ryan
1649172140
$
I'm not sure what would be the best way for vim-recover to detect which one is on the system, though.
hm, interesting. I tried to pull a freebsd docker image and it had gnu stat installed :)
Okay, how about the following patch then:
diff --git a/autoload/recover.vim b/autoload/recover.vim
index 995104f..cd1a57d 100755
--- a/autoload/recover.vim
+++ b/autoload/recover.vim
@@ -42,7 +42,7 @@ fu! s:PIDName(pid) "{{{1
return ''
endfu
fu! s:AttentionMessage(swap_info, pname)
- let statinfo = executable('stat') ? systemlist('stat --printf="%U\n%Y\n" '. a :swap_info['fname']) : []
+ let statinfo = executable('stat') && !has("bsd") ? systemlist('stat --printf= "%U\n%Y\n" '. a:swap_info['fname']) : []
let owner = get(statinfo, 0, '')
let time = get(statinfo, 1, '')
return [ 'E325: ATTENTION',
I saw the commit message. To do this with BSD stat, try:
$ stat -f "%Su\n%m\n" .bashrc
ryan
1638818018
$
ah thanks. I couldn't bend my brain across those printf expandos that night :)
I included your change, hopefully it works.
BSD
stat
is a very different beast than GNUstat
, and BSDstat
ships on macOS. My guess is that's somewhere at the root of this error.I honestly don't know how long this has been going on, since the plugin works fine otherwise and I may not have noticed at all. It's no kind of big deal.