From 83f32093539d259eb2f2cf2fc85148a55b38bb39 Mon Sep 17 00:00:00 2001 From: starinacool Date: Mon, 7 Nov 2016 12:07:24 +0700 Subject: [PATCH] chown for the cases when superuser edit someone else's file --- plugin/AtomicSave.vim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugin/AtomicSave.vim b/plugin/AtomicSave.vim index 4081845..ee4bc7e 100644 --- a/plugin/AtomicSave.vim +++ b/plugin/AtomicSave.vim @@ -9,7 +9,10 @@ function! AtomicSave() echo "error writing file"| return| endif| - + + " chown for the cases when superuser edit someone else's file + call system('! test -e ' . l:filename . ' || chown --reference=' . l:filename . ' ' . l:tempfile)| + " it's hard to grab the perms to make this portable. see http://mywiki.wooledge.org/BashFAQ/087 call system('! test -e ' . l:filename . ' || chmod --reference=' . l:filename . ' ' . l:tempfile)| if v:shell_error|