zip.vim (19786B)
1 " zip.vim: Handles browsing zipfiles 2 " AUTOLOAD PORTION 3 " Date: 2024 Aug 21 4 " Version: 34 5 " Maintainer: This runtime file is looking for a new maintainer. 6 " Former Maintainer: Charles E Campbell 7 " Last Change: 8 " 2024 Jun 16 by Vim Project: handle whitespace on Windows properly (#14998) 9 " 2024 Jul 23 by Vim Project: fix 'x' command 10 " 2024 Jul 24 by Vim Project: use delete() function 11 " 2024 Jul 30 by Vim Project: fix opening remote zipfile 12 " 2024 Aug 04 by Vim Project: escape '[' in name of file to be extracted 13 " 2024 Aug 05 by Vim Project: workaround for the FreeBSD's unzip 14 " 2024 Aug 05 by Vim Project: clean-up and make it work with shellslash on Windows 15 " 2024 Aug 18 by Vim Project: correctly handle special globbing chars 16 " 2024 Aug 21 by Vim Project: simplify condition to detect MS-Windows 17 " 2025 Mar 11 by Vim Project: handle filenames with leading '-' correctly 18 " 2025 Jul 12 by Vim Project: drop ../ on write to prevent path traversal attacks 19 " 2025 Sep 22 by Vim Project: support PowerShell Core 20 " 2025 Dec 20 by Vim Project: use :lcd instead of :cd 21 " 2026 Feb 08 by Vim Project: use system() instead of :! 22 " License: Vim License (see vim's :help license) 23 " Copyright: Copyright (C) 2005-2019 Charles E. Campbell {{{1 24 " Permission is hereby granted to use and distribute this code, 25 " with or without modifications, provided that this copyright 26 " notice is copied with it. Like anything else that's free, 27 " zip.vim and zipPlugin.vim are provided *as is* and comes with 28 " no warranty of any kind, either expressed or implied. By using 29 " this plugin, you agree that in no event will the copyright 30 " holder be liable for any damages resulting from the use 31 " of this software. 32 33 " --------------------------------------------------------------------- 34 " Load Once: {{{1 35 if &cp || exists("g:loaded_zip") 36 finish 37 endif 38 let g:loaded_zip= "v34" 39 let s:keepcpo= &cpo 40 set cpo&vim 41 42 let s:zipfile_escape = ' ?&;\' 43 let s:ERROR = 2 44 let s:WARNING = 1 45 let s:NOTE = 0 46 47 " --------------------------------------------------------------------- 48 " Global Values: {{{1 49 if !exists("g:zip_shq") 50 if &shq != "" 51 let g:zip_shq= &shq 52 elseif has("unix") 53 let g:zip_shq= "'" 54 else 55 let g:zip_shq= '"' 56 endif 57 endif 58 if !exists("g:zip_zipcmd") 59 let g:zip_zipcmd= "zip" 60 endif 61 if !exists("g:zip_unzipcmd") 62 let g:zip_unzipcmd= "unzip" 63 endif 64 if !exists("g:zip_extractcmd") 65 let g:zip_extractcmd= g:zip_unzipcmd 66 endif 67 68 " --------------------------------------------------------------------- 69 " required early 70 " s:Mess: {{{2 71 fun! s:Mess(group, msg) 72 redraw! 73 exe "echohl " . a:group 74 echomsg a:msg 75 echohl Normal 76 endfun 77 78 if !has('nvim-0.10') && v:version < 901 79 " required for defer 80 call s:Mess('WarningMsg', "***warning*** this version of zip needs vim 9.1 or later") 81 finish 82 endif 83 " sanity checks 84 if !executable(g:zip_unzipcmd) && &shell !~ 'pwsh' 85 call s:Mess('Error', "***error*** (zip#Browse) unzip not available on your system") 86 finish 87 endif 88 if !dist#vim#IsSafeExecutable('zip', g:zip_unzipcmd) && &shell !~ 'pwsh' 89 call s:Mess('Error', "Warning: NOT executing " .. g:zip_unzipcmd .. " from current directory!") 90 finish 91 endif 92 93 " ---------------- 94 " PowerShell: {{{1 95 " ---------------- 96 97 function! s:TryExecGnuFallBackToPs(executable, gnu_func_call, ...) 98 " Check that a gnu executable is available, run the gnu_func_call if so. If 99 " the gnu executable is not available or if gnu_func_call fails, try 100 " ps_func_call if &shell =~ 'pwsh'. If all attempts fail, print errors. 101 " a:executable - one of (g:zip_zipcmd, g:zip_unzipcmd, g:zip_extractcmd) 102 " a:gnu_func_call - (string) a gnu function call to execute 103 " a:1 - (optional string) a PowerShell function call to execute. 104 let failures = [] 105 if executable(substitute(a:executable,'\s\+.*$','','')) 106 try 107 exe a:gnu_func_call 108 return 109 catch 110 call add(failures, 'Failed to execute '.a:gnu_func_call) 111 endtry 112 else 113 call add(failures, a:executable.' not available on your system') 114 endif 115 if &shell =~ 'pwsh' && a:0 == 1 116 try 117 exe a:1 118 return 119 catch 120 call add(failures, 'Fallback to PowerShell attempted but failed') 121 endtry 122 endif 123 for msg in failures 124 call s:Mess('Error', msg) 125 endfor 126 endfunction 127 128 129 function! s:ZipBrowsePS(zipfile) 130 " Browse the contents of a zip file using PowerShell's 131 " Equivalent `unzip -Z1 -- zipfile` 132 let cmds = [ 133 \ '$zip = [System.IO.Compression.ZipFile]::OpenRead(' . s:Escape(a:zipfile, 1) . ');', 134 \ '$zip.Entries | ForEach-Object { $_.FullName };', 135 \ '$zip.Dispose()' 136 \ ] 137 return 'pwsh -NoProfile -Command ' . s:Escape(join(cmds, ' '), 1) 138 endfunction 139 140 function! s:ZipReadPS(zipfile, fname, tempfile) 141 " Read a filename within a zipped file to a temporary file. 142 " Equivalent to `unzip -p -- zipfile fname > tempfile` 143 if &shell =~ 'pwsh' 144 call s:Mess('WarningMsg', "***warning*** PowerShell can display, but cannot update, files in archive subfolders") 145 endif 146 let cmds = [ 147 \ '$zip = [System.IO.Compression.ZipFile]::OpenRead(' . s:Escape(a:zipfile, 1) . ');', 148 \ '$fileEntry = $zip.Entries | Where-Object { $_.FullName -eq ' . s:Escape(a:fname, 1) . ' };', 149 \ '$stream = $fileEntry.Open();', 150 \ '$fileStream = [System.IO.File]::Create(' . s:Escape(a:tempfile, 1) . ');', 151 \ '$stream.CopyTo($fileStream);', 152 \ '$fileStream.Close();', 153 \ '$stream.Close();', 154 \ '$zip.Dispose()' 155 \ ] 156 return 'pwsh -NoProfile -Command ' . s:Escape(join(cmds, ' '), 1) 157 endfunction 158 159 function! s:ZipUpdatePS(zipfile, fname) 160 " Update a filename within a zipped file 161 " Equivalent to `zip -u zipfile fname` 162 if a:fname =~ '/' 163 call s:Mess('Error', "***error*** PowerShell cannot update files in archive subfolders") 164 return ':' 165 endif 166 return 'Compress-Archive -Path ' . a:fname . ' -Update -DestinationPath ' . a:zipfile 167 endfunction 168 169 function! s:ZipExtractFilePS(zipfile, fname) 170 " Extract a single file from an archive 171 " Equivalent to `unzip -o zipfile fname` 172 if a:fname =~ '/' 173 call s:Mess('Error', "***error*** PowerShell cannot extract files in archive subfolders") 174 return ':' 175 endif 176 let cmds = [ 177 \ '$zip = [System.IO.Compression.ZipFile]::OpenRead(' . s:Escape(a:zipfile, 1) . ');', 178 \ '$fileEntry = $zip.Entries | Where-Object { $_.FullName -eq ' . a:fname . ' };', 179 \ '$stream = $fileEntry.Open();', 180 \ '$fileStream = [System.IO.File]::Create(' . a:fname . ');', 181 \ '$stream.CopyTo($fileStream);', 182 \ '$fileStream.Close();', 183 \ '$stream.Close();', 184 \ '$zip.Dispose()' 185 \ ] 186 return 'pwsh -NoProfile -Command ' . s:Escape(join(cmds, ' '), 1) 187 endfunction 188 189 function! s:ZipDeleteFilePS(zipfile, fname) 190 " Delete a single file from an archive 191 " Equivalent to `zip -d zipfile fname` 192 let cmds = [ 193 \ 'Add-Type -AssemblyName System.IO.Compression.FileSystem;', 194 \ '$zip = [System.IO.Compression.ZipFile]::Open(' . s:Escape(a:zipfile, 1) . ', ''Update'');', 195 \ '$entry = $zip.Entries | Where-Object { $_.Name -eq ' . s:Escape(a:fname, 1) . ' };', 196 \ 'if ($entry) { $entry.Delete(); $zip.Dispose() }', 197 \ 'else { $zip.Dispose() }' 198 \ ] 199 return 'pwsh -NoProfile -Command ' . s:Escape(join(cmds, ' '), 1) 200 endfunction 201 202 " ---------------- 203 " Functions: {{{1 204 " ---------------- 205 206 " --------------------------------------------------------------------- 207 " zip#Browse: {{{2 208 fun! zip#Browse(zipfile) 209 " sanity check: ensure that the zipfile has "PK" as its first two letters 210 " (zip files have a leading PK as a "magic cookie") 211 if filereadable(a:zipfile) && readblob(a:zipfile, 0, 2) != 0z50.4B 212 exe "noswapfile noautocmd e " .. fnameescape(a:zipfile) 213 return 214 endif 215 216 let dict = s:SetSaneOpts() 217 defer s:RestoreOpts(dict) 218 219 " sanity checks 220 if !executable(g:zip_unzipcmd) && &shell !~ 'pwsh' 221 call s:Mess('Error', "***error*** (zip#Browse) unzip not available on your system") 222 return 223 endif 224 if !filereadable(a:zipfile) 225 if a:zipfile !~# '^\a\+://' 226 " if it's an url, don't complain, let url-handlers such as vim do its thing 227 call s:Mess('Error', "***error*** (zip#Browse) File not readable <".a:zipfile.">") 228 endif 229 return 230 endif 231 if &ma != 1 232 set ma 233 endif 234 let b:zipfile= a:zipfile 235 236 setlocal noswapfile 237 setlocal buftype=nofile 238 setlocal bufhidden=hide 239 setlocal nobuflisted 240 setlocal nowrap 241 242 " Oct 12, 2021: need to re-use Bram's syntax/tar.vim. 243 " Setting the filetype to zip doesn't do anything (currently), 244 " but it is perhaps less confusing to curious perusers who do 245 " a :echo &ft 246 setf zip 247 run! syntax/tar.vim 248 249 " give header 250 call append(0, ['" zip.vim version '.g:loaded_zip, 251 \ '" Browsing zipfile '.a:zipfile, 252 \ '" Select a file with cursor and press ENTER']) 253 keepj $ 254 255 let gnu_cmd = "keepj sil r! " . g:zip_unzipcmd . " -Z1 -- " . s:Escape(a:zipfile, 1) 256 let ps_cmd = 'keepj sil r! ' . s:ZipBrowsePS(a:zipfile) 257 call s:TryExecGnuFallBackToPs(g:zip_unzipcmd, gnu_cmd, ps_cmd) 258 259 if v:shell_error != 0 260 call s:Mess('WarningMsg', "***warning*** (zip#Browse) ".fnameescape(a:zipfile)." is not a zip file") 261 keepj sil! %d 262 let eikeep= &ei 263 set ei=BufReadCmd,FileReadCmd 264 exe "keepj r ".fnameescape(a:zipfile) 265 let &ei= eikeep 266 keepj 1d 267 return 268 endif 269 270 " Maps associated with zip plugin 271 setlocal noma nomod ro 272 noremap <silent> <buffer> <cr> :call <SID>ZipBrowseSelect()<cr> 273 noremap <silent> <buffer> x :call zip#Extract()<cr> 274 if &mouse != "" 275 noremap <silent> <buffer> <leftmouse> <leftmouse>:call <SID>ZipBrowseSelect()<cr> 276 endif 277 278 endfun 279 280 " --------------------------------------------------------------------- 281 " ZipBrowseSelect: {{{2 282 fun! s:ZipBrowseSelect() 283 let dict = s:SetSaneOpts() 284 defer s:RestoreOpts(dict) 285 let fname= getline(".") 286 if !exists("b:zipfile") 287 return 288 endif 289 290 " sanity check 291 if fname =~ '^"' 292 return 293 endif 294 if fname =~ '/$' 295 call s:Mess('Error', "***error*** (zip#Browse) Please specify a file, not a directory") 296 return 297 endif 298 299 " get zipfile to the new-window 300 let zipfile = b:zipfile 301 let curfile = expand("%") 302 303 noswapfile new 304 if !exists("g:zip_nomax") || g:zip_nomax == 0 305 wincmd _ 306 endif 307 let s:zipfile_{winnr()}= curfile 308 exe "noswapfile e ".fnameescape("zipfile://".zipfile.'::'.fname) 309 filetype detect 310 311 endfun 312 313 " --------------------------------------------------------------------- 314 " zip#Read: {{{2 315 fun! zip#Read(fname,mode) 316 let dict = s:SetSaneOpts() 317 defer s:RestoreOpts(dict) 318 319 if has("unix") 320 let zipfile = substitute(a:fname,'zipfile://\(.\{-}\)::[^\\].*$','\1','') 321 let fname = substitute(a:fname,'zipfile://.\{-}::\([^\\].*\)$','\1','') 322 else 323 let zipfile = substitute(a:fname,'^.\{-}zipfile://\(.\{-}\)::[^\\].*$','\1','') 324 let fname = substitute(a:fname,'^.\{-}zipfile://.\{-}::\([^\\].*\)$','\1','') 325 endif 326 let fname = fname->substitute('[', '[[]', 'g')->escape('?*\\') 327 " sanity check 328 if !executable(substitute(g:zip_unzipcmd,'\s\+.*$','','')) && &shell !~ 'pwsh' 329 call s:Mess('Error', "***error*** (zip#Read) sorry, your system doesn't appear to have the ".g:zip_unzipcmd." program") 330 return 331 endif 332 333 " the following code does much the same thing as 334 " exe "keepj sil! r! ".g:zip_unzipcmd." -p -- ".s:Escape(zipfile,1)." ".s:Escape(fname,1) 335 " but allows zipfile://... entries in quickfix lists 336 let temp = tempname() 337 let fn = expand('%:p') 338 339 let gnu_cmd = g:zip_unzipcmd . ' -p -- ' . s:Escape(zipfile, 0) . ' ' . s:Escape(fname, 0) . ' > ' . s:Escape(temp, 0) 340 let gnu_cmd = 'call system(''' . substitute(gnu_cmd, "'", "''", 'g') . ''')' 341 let ps_cmd = 'sil !' . s:ZipReadPS(zipfile, fname, temp) 342 call s:TryExecGnuFallBackToPs(g:zip_unzipcmd, gnu_cmd, ps_cmd) 343 344 sil exe 'keepalt file '.temp 345 sil keepj e! 346 sil exe 'keepalt file '.fnameescape(fn) 347 call delete(temp) 348 349 filetype detect 350 351 " cleanup 352 set nomod 353 354 endfun 355 356 " --------------------------------------------------------------------- 357 " zip#Write: {{{2 358 fun! zip#Write(fname) 359 let dict = s:SetSaneOpts() 360 let need_rename = 0 361 defer s:RestoreOpts(dict) 362 363 " sanity checks 364 if !executable(substitute(g:zip_zipcmd,'\s\+.*$','','')) && &shell !~ 'pwsh' 365 call s:Mess('Error', "***error*** (zip#Write) sorry, your system doesn't appear to have the ".g:zip_zipcmd." program") 366 return 367 endif 368 369 let curdir= getcwd() 370 let tmpdir= tempname() 371 if tmpdir =~ '\.' 372 let tmpdir= substitute(tmpdir,'\.[^.]*$','','e') 373 endif 374 call mkdir(tmpdir,"p") 375 376 " attempt to change to the indicated directory 377 if s:ChgDir(tmpdir,s:ERROR,"(zip#Write) cannot lcd to temporary directory") 378 return 379 endif 380 381 " place temporary files under .../_ZIPVIM_/ 382 if isdirectory("_ZIPVIM_") 383 call delete("_ZIPVIM_", "rf") 384 endif 385 call mkdir("_ZIPVIM_") 386 lcd _ZIPVIM_ 387 388 if has("unix") 389 let zipfile = substitute(a:fname,'zipfile://\(.\{-}\)::[^\\].*$','\1','') 390 let fname = substitute(a:fname,'zipfile://.\{-}::\([^\\].*\)$','\1','') 391 else 392 let zipfile = substitute(a:fname,'^.\{-}zipfile://\(.\{-}\)::[^\\].*$','\1','') 393 let fname = substitute(a:fname,'^.\{-}zipfile://.\{-}::\([^\\].*\)$','\1','') 394 endif 395 if fname =~ '^[.]\{1,2}/' 396 let gnu_cmd = g:zip_zipcmd . ' -d ' . s:Escape(fnamemodify(zipfile,":p"),0) . ' ' . s:Escape(fname,0) 397 let gnu_cmd = 'call system(''' . substitute(gnu_cmd, "'", "''", 'g') . ''')' 398 let ps_cmd = $"call system({s:Escape(s:ZipDeleteFilePS(zipfile, fname), 1)})" 399 call s:TryExecGnuFallBackToPs(g:zip_zipcmd, gnu_cmd, ps_cmd) 400 let fname = fname->substitute('^\([.]\{1,2}/\)\+', '', 'g') 401 let need_rename = 1 402 endif 403 404 if fname =~ '/' 405 let dirpath = substitute(fname,'/[^/]\+$','','e') 406 if has("win32unix") && executable("cygpath") 407 let dirpath = substitute(system("cygpath ".s:Escape(dirpath,0)),'\n','','e') 408 endif 409 call mkdir(dirpath,"p") 410 endif 411 if zipfile !~ '/' 412 let zipfile= curdir.'/'.zipfile 413 endif 414 415 " don't overwrite files forcefully 416 exe "w ".fnameescape(fname) 417 if has("win32unix") && executable("cygpath") 418 let zipfile = substitute(system("cygpath ".s:Escape(zipfile,0)),'\n','','e') 419 endif 420 421 if (has("win32") || has("win95") || has("win64") || has("win16")) && &shell !~? 'sh$' 422 let fname = substitute(fname, '[', '[[]', 'g') 423 endif 424 425 let gnu_cmd = g:zip_zipcmd . ' -u '. s:Escape(fnamemodify(zipfile,":p"),0) . ' ' . s:Escape(fname,0) 426 let gnu_cmd = 'call system(''' . substitute(gnu_cmd, "'", "''", 'g') . ''')' 427 let ps_cmd = s:ZipUpdatePS(s:Escape(fnamemodify(zipfile, ':p'), 0), s:Escape(fname, 0)) 428 let ps_cmd = 'call system(''' . substitute(ps_cmd, "'", "''", 'g') . ''')' 429 call s:TryExecGnuFallBackToPs(g:zip_zipcmd, gnu_cmd, ps_cmd) 430 if &shell =~ 'pwsh' 431 " Vim flashes 'creation in progress ...' from what I believe is the 432 " ProgressAction stream of PowerShell. Unfortunately, this cannot be 433 " suppressed (as of 250824) due to an open PowerShell issue. 434 " https://github.com/PowerShell/PowerShell/issues/21074 435 " This necessitates a redraw of the buffer. 436 redraw! 437 endif 438 439 if v:shell_error != 0 440 call s:Mess('Error', "***error*** (zip#Write) sorry, unable to update ".zipfile." with ".fname) 441 442 elseif s:zipfile_{winnr()} =~ '^\a\+://' 443 " support writing zipfiles across a network 444 let netzipfile= s:zipfile_{winnr()} 445 1split|enew 446 let binkeep= &binary 447 let eikeep = &ei 448 set binary ei=all 449 exe "noswapfile e! ".fnameescape(zipfile) 450 call netrw#NetWrite(netzipfile) 451 let &ei = eikeep 452 let &binary = binkeep 453 q! 454 unlet s:zipfile_{winnr()} 455 elseif need_rename 456 exe $"sil keepalt file {fnameescape($"zipfile://{zipfile}::{fname}")}" 457 call s:Mess('Warning', "***error*** (zip#Browse) Path Traversal Attack detected, dropping relative path") 458 endif 459 460 " cleanup and restore current directory 461 lcd .. 462 call delete("_ZIPVIM_", "rf") 463 call s:ChgDir(curdir,s:WARNING,"(zip#Write) unable to return to ".curdir."!") 464 call delete(tmpdir, "rf") 465 setlocal nomod 466 endfun 467 468 " --------------------------------------------------------------------- 469 " zip#Extract: extract a file from a zip archive {{{2 470 fun! zip#Extract() 471 472 let dict = s:SetSaneOpts() 473 defer s:RestoreOpts(dict) 474 let fname= getline(".") 475 476 " sanity check 477 if fname =~ '^"' 478 return 479 endif 480 if fname =~ '/$' 481 call s:Mess('Error', "***error*** (zip#Extract) Please specify a file, not a directory") 482 return 483 elseif fname =~ '^[.]\?[.]/' 484 call s:Mess('Error', "***error*** (zip#Browse) Path Traversal Attack detected, not extracting!") 485 return 486 endif 487 if filereadable(fname) 488 call s:Mess('Error', "***error*** (zip#Extract) <" .. fname .."> already exists in directory, not overwriting!") 489 return 490 endif 491 let target = fname->substitute('\[', '[[]', 'g') 492 " unzip 6.0 does not support -- to denote end-of-arguments 493 " unzip 6.1 (2010) apparently supports, it, but hasn't been released 494 " so the workaround is to use glob '[-]' so that it won't be considered an argument 495 " else, it would be possible to use 'unzip -o <file.zip> '-d/tmp' to extract the whole archive 496 let target = target->substitute('^-', '[&]', '') 497 if &shell =~ 'cmd' && has("win32") 498 let target = target 499 \ ->substitute('[?*]', '[&]', 'g') 500 \ ->substitute('[\\]', '?', 'g') 501 \ ->shellescape() 502 " there cannot be a file name with '\' in its name, unzip replaces it by _ 503 let fname = fname->substitute('[\\?*]', '_', 'g') 504 else 505 let target = target->escape('*?\\')->shellescape() 506 endif 507 508 " extract the file mentioned under the cursor 509 let gnu_cmd = g:zip_extractcmd . ' -o '. shellescape(b:zipfile) . ' ' . target 510 let gnu_cmd = 'call system(''' . substitute(gnu_cmd, "'", "''", 'g') . ''')' 511 let ps_cmd = $"call system({s:Escape(s:ZipExtractFilePS(b:zipfile, target), 1)})" 512 call s:TryExecGnuFallBackToPs(g:zip_extractcmd, gnu_cmd, ps_cmd) 513 514 if v:shell_error != 0 515 call s:Mess('Error', "***error*** ".g:zip_extractcmd." ".b:zipfile." ".fname.": failed!") 516 elseif !filereadable(fname) && &shell !~ 'pwsh' 517 call s:Mess('Error', "***error*** attempted to extract ".fname." but it doesn't appear to be present!") 518 else 519 echomsg "***note*** successfully extracted ".fname 520 endif 521 endfun 522 523 " --------------------------------------------------------------------- 524 " s:Escape: {{{2 525 fun! s:Escape(fname,isfilt) 526 if exists("*shellescape") 527 if a:isfilt 528 let qnameq= shellescape(a:fname,1) 529 else 530 let qnameq= shellescape(a:fname) 531 endif 532 else 533 let qnameq= g:zip_shq.escape(a:fname,g:zip_shq).g:zip_shq 534 endif 535 return qnameq 536 endfun 537 538 " --------------------------------------------------------------------- 539 " s:ChgDir: {{{2 540 fun! s:ChgDir(newdir,errlvl,errmsg) 541 try 542 exe "lcd ".fnameescape(a:newdir) 543 catch /^Vim\%((\a\+)\)\=:E344/ 544 redraw! 545 if a:errlvl == s:NOTE 546 echomsg "***note*** ".a:errmsg 547 elseif a:errlvl == s:WARNING 548 call s:Mess("WarningMsg", "***warning*** ".a:errmsg) 549 elseif a:errlvl == s:ERROR 550 call s:Mess("Error", "***error*** ".a:errmsg) 551 endif 552 return 1 553 endtry 554 555 return 0 556 endfun 557 558 " --------------------------------------------------------------------- 559 " s:SetSaneOpts: {{{2 560 fun! s:SetSaneOpts() 561 let dict = {} 562 let dict.report = &report 563 let dict.shellslash = &shellslash 564 565 let &report = 10 566 if exists('+shellslash') 567 let &shellslash = 0 568 endif 569 570 return dict 571 endfun 572 573 " --------------------------------------------------------------------- 574 " s:RestoreOpts: {{{2 575 fun! s:RestoreOpts(dict) 576 for [key, val] in items(a:dict) 577 exe $"let &{key} = {val}" 578 endfor 579 endfun 580 581 " ------------------------------------------------------------------------ 582 " Modelines And Restoration: {{{1 583 let &cpo= s:keepcpo 584 unlet s:keepcpo 585 " vim:ts=8 fdm=marker