@@ -32,6 +32,13 @@ function! xolox#misc#perm#update(fname, contents)
32
32
" The second argument is the list of lines to be written to the file. Writes
33
33
" the new contents to a temporary file and renames the temporary file into
34
34
" place, thereby preventing readers from reading a partially written file.
35
+ " Returns 1 if the file is successfully updated, 0 otherwise.
36
+ "
37
+ " Note that if `xolox#misc#perm#get()` and `xolox#misc#perm#set()` cannot be
38
+ " used to preserve the file owner/group/mode the file is still updated using
39
+ " a rename (for compatibility with non-UNIX systems and incompatible
40
+ " `/usr/bin/stat` implementations) so in that case you can still lose the
41
+ " file's owner/group/mode.
35
42
let starttime = xolox#misc#timer#start ()
36
43
let temporary_file = printf (' %s.tmp' , a: fname )
37
44
call xolox#misc#msg#debug (" vim-misc %s: Writing new contents of %s to temporary file %s .." , g: xolox #misc#version , a: fname , temporary_file)
@@ -56,7 +63,7 @@ function! xolox#misc#perm#get(fname)
56
63
let pathname = xolox#misc#path#absolute (a: fname )
57
64
if filereadable (pathname)
58
65
let command = printf (' stat --format %s %s' , ' %U:%G:%a' , shellescape (pathname))
59
- let result = xolox#misc#os#exec ({' command' : command })
66
+ let result = xolox#misc#os#exec ({' command' : command , ' check ' : 0 })
60
67
if result[' exit_code' ] == 0 && len (result[' stdout' ]) >= 1
61
68
let tokens = split (result[' stdout' ][0 ], ' :' )
62
69
if len (tokens) == 3
@@ -88,6 +95,6 @@ endfunction
88
95
function ! s: run (command , ... )
89
96
let args = map (copy (a: 000 ), ' shellescape(v:val)' )
90
97
call insert (args , a: command , 0 )
91
- let result = xolox#misc#os#exec ({' command' : call (' printf' , args )})
98
+ let result = xolox#misc#os#exec ({' command' : call (' printf' , args ), ' check ' : 0 })
92
99
return result[' exit_code' ] == 0
93
100
endfunction
0 commit comments