114 \ 'funcref': type(function('call')) |
114 \ 'funcref': type(function('call')) |
115 \ } |
115 \ } |
116 let s:loaded = get(s:, 'loaded', {}) |
116 let s:loaded = get(s:, 'loaded', {}) |
117 let s:triggers = get(s:, 'triggers', {}) |
117 let s:triggers = get(s:, 'triggers', {}) |
118 |
118 |
|
119 function! s:is_powershell(shell) |
|
120 return a:shell =~# 'powershell\(\.exe\)\?$' || a:shell =~# 'pwsh\(\.exe\)\?$' |
|
121 endfunction |
|
122 |
119 function! s:isabsolute(dir) abort |
123 function! s:isabsolute(dir) abort |
120 return a:dir =~# '^/' || (has('win32') && a:dir =~? '^\%(\\\|[A-Z]:\)') |
124 return a:dir =~# '^/' || (has('win32') && a:dir =~? '^\%(\\\|[A-Z]:\)') |
121 endfunction |
125 endfunction |
122 |
126 |
123 function! s:git_dir(dir) abort |
127 function! s:git_dir(dir) abort |
261 if !executable('git') |
265 if !executable('git') |
262 return s:err('`git` executable not found. Most commands will not be available. To suppress this message, prepend `silent!` to `call plug#begin(...)`.') |
266 return s:err('`git` executable not found. Most commands will not be available. To suppress this message, prepend `silent!` to `call plug#begin(...)`.') |
263 endif |
267 endif |
264 if has('win32') |
268 if has('win32') |
265 \ && &shellslash |
269 \ && &shellslash |
266 \ && (&shell =~# 'cmd\(\.exe\)\?$' || &shell =~# 'powershell\(\.exe\)\?$') |
270 \ && (&shell =~# 'cmd\(\.exe\)\?$' || s:is_powershell(&shell)) |
267 return s:err('vim-plug does not support shell, ' . &shell . ', when shellslash is set.') |
271 return s:err('vim-plug does not support shell, ' . &shell . ', when shellslash is set.') |
268 endif |
272 endif |
269 if !has('nvim') |
273 if !has('nvim') |
270 \ && (has('win32') || has('win32unix')) |
274 \ && (has('win32') || has('win32unix')) |
271 \ && !has('multi_byte') |
275 \ && !has('multi_byte') |
501 |
505 |
502 function! s:batchfile(cmd) |
506 function! s:batchfile(cmd) |
503 let batchfile = s:plug_tempname().'.bat' |
507 let batchfile = s:plug_tempname().'.bat' |
504 call writefile(s:wrap_cmds(a:cmd), batchfile) |
508 call writefile(s:wrap_cmds(a:cmd), batchfile) |
505 let cmd = plug#shellescape(batchfile, {'shell': &shell, 'script': 0}) |
509 let cmd = plug#shellescape(batchfile, {'shell': &shell, 'script': 0}) |
506 if &shell =~# 'powershell\(\.exe\)\?$' |
510 if s:is_powershell(&shell) |
507 let cmd = '& ' . cmd |
511 let cmd = '& ' . cmd |
508 endif |
512 endif |
509 return [batchfile, cmd] |
513 return [batchfile, cmd] |
510 endfunction |
514 endfunction |
511 else |
515 else |
973 let prev = [&shell, &shellcmdflag, &shellredir] |
986 let prev = [&shell, &shellcmdflag, &shellredir] |
974 if !s:is_win |
987 if !s:is_win |
975 set shell=sh |
988 set shell=sh |
976 endif |
989 endif |
977 if a:swap |
990 if a:swap |
978 if &shell =~# 'powershell\(\.exe\)\?$' || &shell =~# 'pwsh$' |
991 if s:is_powershell(&shell) |
979 let &shellredir = '2>&1 | Out-File -Encoding UTF8 %s' |
992 let &shellredir = '2>&1 | Out-File -Encoding UTF8 %s' |
980 elseif &shell =~# 'sh' || &shell =~# 'cmd\(\.exe\)\?$' |
993 elseif &shell =~# 'sh' || &shell =~# 'cmd\(\.exe\)\?$' |
981 set shellredir=>%s\ 2>&1 |
994 set shellredir=>%s\ 2>&1 |
982 endif |
995 endif |
983 endif |
996 endif |
2214 let opts = a:0 > 0 && type(a:1) == s:TYPE.dict ? a:1 : {} |
2227 let opts = a:0 > 0 && type(a:1) == s:TYPE.dict ? a:1 : {} |
2215 let shell = get(opts, 'shell', s:is_win ? 'cmd.exe' : 'sh') |
2228 let shell = get(opts, 'shell', s:is_win ? 'cmd.exe' : 'sh') |
2216 let script = get(opts, 'script', 1) |
2229 let script = get(opts, 'script', 1) |
2217 if shell =~# 'cmd\(\.exe\)\?$' |
2230 if shell =~# 'cmd\(\.exe\)\?$' |
2218 return s:shellesc_cmd(a:arg, script) |
2231 return s:shellesc_cmd(a:arg, script) |
2219 elseif shell =~# 'powershell\(\.exe\)\?$' || shell =~# 'pwsh$' |
2232 elseif s:is_powershell(shell) |
2220 return s:shellesc_ps1(a:arg) |
2233 return s:shellesc_ps1(a:arg) |
2221 endif |
2234 endif |
2222 return s:shellesc_sh(a:arg) |
2235 return s:shellesc_sh(a:arg) |
2223 endfunction |
2236 endfunction |
2224 |
2237 |
2266 " Assume that the command does not rely on the shell. |
2279 " Assume that the command does not rely on the shell. |
2267 if has('nvim') && a:0 == 0 |
2280 if has('nvim') && a:0 == 0 |
2268 return system(a:cmd) |
2281 return system(a:cmd) |
2269 endif |
2282 endif |
2270 let cmd = join(map(copy(a:cmd), 'plug#shellescape(v:val, {"shell": &shell, "script": 0})')) |
2283 let cmd = join(map(copy(a:cmd), 'plug#shellescape(v:val, {"shell": &shell, "script": 0})')) |
2271 if &shell =~# 'powershell\(\.exe\)\?$' |
2284 if s:is_powershell(&shell) |
2272 let cmd = '& ' . cmd |
2285 let cmd = '& ' . cmd |
2273 endif |
2286 endif |
2274 else |
2287 else |
2275 let cmd = a:cmd |
2288 let cmd = a:cmd |
2276 endif |
2289 endif |