diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2019-05-29 01:37:48 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2019-05-29 01:37:48 +1200 |
commit | 980f96002ed6eaf548d31ac4aca57486fc1a308b (patch) | |
tree | 052b0b6b47341ea91400631e2bd588f9fdf80058 | |
parent | Merge branch 'hotfix/v1.0.1' (diff) | |
parent | Bump VERSION (diff) | |
download | vim-shebang-create-exec-master.tar.gz vim-shebang-create-exec-master.zip |
* release/v1.1.0:
Add file existence check before making executable
Use local variable for filename and readability
-rw-r--r-- | VERSION | 2 | ||||
-rw-r--r-- | autoload/shebang_create_exec.vim | 12 |
2 files changed, 9 insertions, 5 deletions
@@ -1 +1 @@ -1.0.1 +1.1.0 diff --git a/autoload/shebang_create_exec.vim b/autoload/shebang_create_exec.vim index 60d2276..cfd08f5 100644 --- a/autoload/shebang_create_exec.vim +++ b/autoload/shebang_create_exec.vim @@ -30,10 +30,14 @@ function! s:Run(filename) abort return endif - " Check that it matches the file we just saved, and if so, make that file - " executable - if a:filename ==# b:shebang_create_exec_filename - call s:MakeExecutable(b:shebang_create_exec_filename) + " Get argument filename into local variable + let filename = a:filename + + " Check that it matches the file we just saved, and that the file exists, + " and if so, attempt to make it executable + if filename ==# b:shebang_create_exec_filename + \ && filereadable(filename) + call s:MakeExecutable(filename) endif " Clear away the save filename, even if we didn't change any permissions |