mirror of
https://github.com/junegunn/vim-plug.git
synced 2024-12-24 04:56:33 -07:00
Fix Windows Batch file format
`writefile()` always output LF without CR each lines. But batch file on windows needs CR and LF, at end of lines. And if the path of home directory contains non-ASCII characters like Japanese username (e.g. `C:\Users\太郎`), batch file without CR can't be executed correctly.
This commit is contained in:
parent
e6a775e0df
commit
9f943e6201
6
plug.vim
6
plug.vim
@ -1196,7 +1196,7 @@ function! s:spawn(name, cmd, opts)
|
|||||||
let s:jobs[a:name] = job
|
let s:jobs[a:name] = job
|
||||||
let cmd = has_key(a:opts, 'dir') ? s:with_cd(a:cmd, a:opts.dir) : a:cmd
|
let cmd = has_key(a:opts, 'dir') ? s:with_cd(a:cmd, a:opts.dir) : a:cmd
|
||||||
if !empty(job.batchfile)
|
if !empty(job.batchfile)
|
||||||
call writefile(['@echo off', cmd], job.batchfile)
|
call writefile(["@echo off\r", cmd], job.batchfile)
|
||||||
let cmd = job.batchfile
|
let cmd = job.batchfile
|
||||||
endif
|
endif
|
||||||
let argv = add(s:is_win ? ['cmd', '/c'] : ['sh', '-c'], cmd)
|
let argv = add(s:is_win ? ['cmd', '/c'] : ['sh', '-c'], cmd)
|
||||||
@ -2023,7 +2023,7 @@ function! s:system(cmd, ...)
|
|||||||
let cmd = a:0 > 0 ? s:with_cd(a:cmd, a:1) : a:cmd
|
let cmd = a:0 > 0 ? s:with_cd(a:cmd, a:1) : a:cmd
|
||||||
if s:is_win
|
if s:is_win
|
||||||
let batchfile = tempname().'.bat'
|
let batchfile = tempname().'.bat'
|
||||||
call writefile(['@echo off', cmd], batchfile)
|
call writefile(["@echo off\r", cmd], batchfile)
|
||||||
let cmd = batchfile
|
let cmd = batchfile
|
||||||
endif
|
endif
|
||||||
return system(s:is_win ? '('.cmd.')' : cmd)
|
return system(s:is_win ? '('.cmd.')' : cmd)
|
||||||
@ -2357,7 +2357,7 @@ function! s:preview_commit()
|
|||||||
let cmd = 'cd '.s:shellesc(g:plugs[name].dir).' && git show --no-color --pretty=medium '.sha
|
let cmd = 'cd '.s:shellesc(g:plugs[name].dir).' && git show --no-color --pretty=medium '.sha
|
||||||
if s:is_win
|
if s:is_win
|
||||||
let batchfile = tempname().'.bat'
|
let batchfile = tempname().'.bat'
|
||||||
call writefile(['@echo off', cmd], batchfile)
|
call writefile(["@echo off\r", cmd], batchfile)
|
||||||
let cmd = batchfile
|
let cmd = batchfile
|
||||||
endif
|
endif
|
||||||
execute 'silent %!' cmd
|
execute 'silent %!' cmd
|
||||||
|
Loading…
Reference in New Issue
Block a user