Merge branch 'vim-with-runtime' into feat/quickfix-title
[vim_extended.git] / runtime / autoload / tar.vim
blob3e44579ce19ee779f488dcb6fd9a4a4a698c812c
1 " tar.vim: Handles browsing tarfiles
2 "            AUTOLOAD PORTION
3 " Date:                 Dec 28, 2009
4 " Version:              24
5 " Maintainer:   Charles E Campbell, Jr <NdrOchip@ScampbellPfamily.AbizM-NOSPAM>
6 " License:              Vim License  (see vim's :help license)
8 "       Contains many ideas from Michael Toren's <tar.vim>
10 " Copyright:    Copyright (C) 2005-2009 Charles E. Campbell, Jr. {{{1
11 "               Permission is hereby granted to use and distribute this code,
12 "               with or without modifications, provided that this copyright
13 "               notice is copied with it. Like anything else that's free,
14 "               tar.vim and tarPlugin.vim are provided *as is* and comes
15 "               with no warranty of any kind, either expressed or implied.
16 "               By using this plugin, you agree that in no event will the
17 "               copyright holder be liable for any damages resulting from
18 "               the use of this software.
19 "     call inputsave()|call input("Press <cr> to continue")|call inputrestore()
20 " ---------------------------------------------------------------------
21 " Load Once: {{{1
22 if &cp || exists("g:loaded_tar")
23  finish
24 endif
25 let g:loaded_tar= "v24"
26 if v:version < 702
27  echohl WarningMsg
28  echo "***warning*** this version of tar needs vim 7.2"
29  echohl Normal
30  finish
31 endif
32 let s:keepcpo= &cpo
33 set cpo&vim
34 "call Decho("loading autoload/tar.vim")
36 " ---------------------------------------------------------------------
37 "  Default Settings: {{{1
38 if !exists("g:tar_browseoptions")
39  let g:tar_browseoptions= "Ptf"
40 endif
41 if !exists("g:tar_readoptions")
42  let g:tar_readoptions= "OPxf"
43 endif
44 if !exists("g:tar_cmd")
45  let g:tar_cmd= "tar"
46 endif
47 if !exists("g:tar_writeoptions")
48  let g:tar_writeoptions= "uf"
49 endif
50 if !exists("g:tar_copycmd")
51  if !exists("g:netrw_localcopycmd")
52   if has("win32") || has("win95") || has("win64") || has("win16")
53    if g:netrw_cygwin
54     let g:netrw_localcopycmd= "cp"
55    else
56     let g:netrw_localcopycmd= "copy"
57    endif
58   elseif has("unix") || has("macunix")
59    let g:netrw_localcopycmd= "cp"
60   else
61    let g:netrw_localcopycmd= ""
62   endif
63  endif
64  let g:tar_copycmd= g:netrw_localcopycmd
65 endif
66 if !exists("g:netrw_cygwin")
67  if has("win32") || has("win95") || has("win64") || has("win16")
68   if &shell =~ '\%(\<bash\>\|\<zsh\>\)\%(\.exe\)\=$'
69    let g:netrw_cygwin= 1
70   else
71    let g:netrw_cygwin= 0
72   endif
73  else
74   let g:netrw_cygwin= 0
75  endif
76 endif
77 if !exists("g:tar_extractcmd")
78  let g:tar_extractcmd= "tar -xf"
79 endif
81 " set up shell quoting character
82 if !exists("g:tar_shq")
83  if exists("&shq") && &shq != ""
84   let g:tar_shq= &shq
85  elseif has("win32") || has("win95") || has("win64") || has("win16")
86   if exists("g:netrw_cygwin") && g:netrw_cygwin
87    let g:tar_shq= "'"
88   else
89    let g:tar_shq= '"'
90   endif
91  else
92   let g:tar_shq= "'"
93  endif
94 " call Decho("g:tar_shq<".g:tar_shq.">")
95 endif
97 " ----------------
98 "  Functions: {{{1
99 " ----------------
101 " ---------------------------------------------------------------------
102 " tar#Browse: {{{2
103 fun! tar#Browse(tarfile)
104 "  call Dfunc("tar#Browse(tarfile<".a:tarfile.">)")
105   let repkeep= &report
106   set report=10
108   " sanity checks
109   if !executable(g:tar_cmd)
110    redraw!
111    echohl Error | echo '***error*** (tar#Browse) "'.g:tar_cmd.'" not available on your system'
112    let &report= repkeep
113 "   call Dret("tar#Browse")
114    return
115   endif
116   if !filereadable(a:tarfile)
117 "   call Decho('a:tarfile<'.a:tarfile.'> not filereadable')
118    if a:tarfile !~# '^\a\+://'
119     " if its an url, don't complain, let url-handlers such as vim do its thing
120     redraw!
121     echohl Error | echo "***error*** (tar#Browse) File not readable<".a:tarfile.">" | echohl None
122    endif
123    let &report= repkeep
124 "   call Dret("tar#Browse : file<".a:tarfile."> not readable")
125    return
126   endif
127   if &ma != 1
128    set ma
129   endif
130   let w:tarfile= a:tarfile
132   setlocal noswapfile
133   setlocal buftype=nofile
134   setlocal bufhidden=hide
135   setlocal nobuflisted
136   setlocal nowrap
137   set ft=tar
139   " give header
140 "  call Decho("printing header")
141   let lastline= line("$")
142   call setline(lastline+1,'" tar.vim version '.g:loaded_tar)
143   call setline(lastline+2,'" Browsing tarfile '.a:tarfile)
144   call setline(lastline+3,'" Select a file with cursor and press ENTER')
145   $put =''
146   0d
147   $
149   let tarfile= a:tarfile
150   if has("win32") && executable("cygpath")
151    " assuming cygwin
152    let tarfile=substitute(system("cygpath -u ".shellescape(tarfile,0)),'\n$','','e')
153   endif
154   let curlast= line("$")
155   if tarfile =~# '\.\(gz\|tgz\)$'
156 "   call Decho("1: exe silent r! gzip -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - ")
157    exe "silent r! gzip -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
158   elseif tarfile =~# '\.lrp'
159 "   call Decho("2: exe silent r! cat -- ".shellescape(tarfile,1)."|gzip -d -c -|".g:tar_cmd." -".g:tar_browseoptions." - ")
160    exe "silent r! cat -- ".shellescape(tarfile,1)."|gzip -d -c -|".g:tar_cmd." -".g:tar_browseoptions." - "
161   elseif tarfile =~# '\.bz2$'
162 "   call Decho("3: exe silent r! bzip2 -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - ")
163    exe "silent r! bzip2 -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
164   elseif tarfile =~# '\.lzma$'
165 "   call Decho("3: exe silent r! lzma -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - ")
166    exe "silent r! lzma -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
167   else
168    if tarfile =~ '^\s*-'
169     " A file name starting with a dash is taken as an option.  Prepend ./ to avoid that.
170     let tarfile = substitute(tarfile, '-', './-', '')
171    endif
172 "   call Decho("4: exe silent r! ".g:tar_cmd." -".g:tar_browseoptions." ".shellescape(tarfile,0))
173    exe "silent r! ".g:tar_cmd." -".g:tar_browseoptions." ".shellescape(tarfile,1)
174   endif
175   if v:shell_error != 0
176    redraw!
177    echohl WarningMsg | echo "***warning*** (tar#Browse) please check your g:tar_browseoptions<".g:tar_browseoptions.">"
178 "   call Dret("tar#Browse : a:tarfile<".a:tarfile.">")
179    return
180   endif
181   if line("$") == curlast || ( line("$") == (curlast + 1) && getline("$") =~ '\c\%(warning\|error\|inappropriate\|unrecognized\)')
182    redraw!
183    echohl WarningMsg | echo "***warning*** (tar#Browse) ".a:tarfile." doesn't appear to be a tar file" | echohl None
184    silent %d
185    let eikeep= &ei
186    set ei=BufReadCmd,FileReadCmd
187    exe "r ".fnameescape(a:tarfile)
188    let &ei= eikeep
189    1d
190 "   call Dret("tar#Browse : a:tarfile<".a:tarfile.">")
191    return
192   endif
194   setlocal noma nomod ro
195   noremap <silent> <buffer> <cr> :call <SID>TarBrowseSelect()<cr>
197   let &report= repkeep
198 "  call Dret("tar#Browse : w:tarfile<".w:tarfile.">")
199 endfun
201 " ---------------------------------------------------------------------
202 " TarBrowseSelect: {{{2
203 fun! s:TarBrowseSelect()
204 "  call Dfunc("TarBrowseSelect() w:tarfile<".w:tarfile."> curfile<".expand("%").">")
205   let repkeep= &report
206   set report=10
207   let fname= getline(".")
208 "  call Decho("fname<".fname.">")
210   if !exists("g:tar_secure") && fname =~ '^\s*-\|\s\+-'
211    redraw!
212    echohl WarningMsg | echo '***warning*** (tar#BrowseSelect) rejecting tarfile member<'.fname.'> because of embedded "-"'
213 "   call Dret('tar#BrowseSelect : rejecting tarfile member<'.fname.'> because of embedded "-"')
214    return
215   endif
217   " sanity check
218   if fname =~ '^"'
219    let &report= repkeep
220 "   call Dret("TarBrowseSelect")
221    return
222   endif
224   " about to make a new window, need to use w:tarfile
225   let tarfile= w:tarfile
226   let curfile= expand("%")
227   if has("win32") && executable("cygpath")
228    " assuming cygwin
229    let tarfile=substitute(system("cygpath -u ".shellescape(tarfile,0)),'\n$','','e')
230   endif
232   new
233   if !exists("g:tar_nomax") || g:tar_nomax == 0
234    wincmd _
235   endif
236   let s:tblfile_{winnr()}= curfile
237   call tar#Read("tarfile:".tarfile.'::'.fname,1)
238   filetype detect
240   let &report= repkeep
241 "  call Dret("TarBrowseSelect : s:tblfile_".winnr()."<".s:tblfile_{winnr()}.">")
242 endfun
244 " ---------------------------------------------------------------------
245 " tar#Read: {{{2
246 fun! tar#Read(fname,mode)
247 "  call Dfunc("tar#Read(fname<".a:fname.">,mode=".a:mode.")")
248   let repkeep= &report
249   set report=10
250   let tarfile = substitute(a:fname,'tarfile:\(.\{-}\)::.*$','\1','')
251   let fname   = substitute(a:fname,'tarfile:.\{-}::\(.*\)$','\1','')
252   if has("win32") && executable("cygpath")
253    " assuming cygwin
254    let tarfile=substitute(system("cygpath -u ".shellescape(tarfile,0)),'\n$','','e')
255   endif
256 "  call Decho("tarfile<".tarfile.">")
257 "  call Decho("fname<".fname.">")
259   if  fname =~ '\.bz2$' && executable("bzcat")
260    let decmp= "|bzcat"
261    let doro = 1
262   elseif      fname =~ '\.gz$'  && executable("zcat")
263    let decmp= "|zcat"
264    let doro = 1
265   elseif  fname =~ '\.lzma$' && executable("lzcat")
266    let decmp= "|lzcat"
267    let doro = 1
268   else
269    let decmp=""
270    let doro = 0
271    if fname =~ '\.bz2$\|\.gz$\|\.lzma$\|\.zip$\|\.Z$'
272     setlocal bin
273    endif
274   endif
276   if exists("g:tar_secure")
277    let tar_secure= " -- "
278   else
279    let tar_secure= " "
280   endif
281   if tarfile =~# '\.bz2$'
282 "   call Decho("7: exe silent r! bzip2 -d -c ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp)
283    exe "silent r! bzip2 -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
284   elseif tarfile =~# '\.\(gz\|tgz\)$'
285 "   call Decho("5: exe silent r! gzip -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd.' -'.g:tar_readoptions.' - '.tar_secure.shellescape(fname,1))
286    exe "silent r! gzip -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
287   elseif tarfile =~# '\.lrp$'
288 "   call Decho("6: exe silent r! cat ".shellescape(tarfile,1)." | gzip -d -c - | ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp)
289    exe "silent r! cat -- ".shellescape(tarfile,1)." | gzip -d -c - | ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
290   elseif tarfile =~# '\.lzma$'
291 "   call Decho("7: exe silent r! lzma -d -c ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp)
292    exe "silent r! lzma -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
293   else
294    if tarfile =~ '^\s*-'
295     " A file name starting with a dash is taken as an option.  Prepend ./ to avoid that.
296     let tarfile = substitute(tarfile, '-', './-', '')
297    endif
298 "   call Decho("8: exe silent r! ".g:tar_cmd." -".g:tar_readoptions.tar_secure.shellescape(tarfile,1)." ".shellescape(fname,1).decmp)
299    exe "silent r! ".g:tar_cmd." -".g:tar_readoptions.shellescape(tarfile,1)." ".tar_secure.shellescape(fname,1).decmp
300   endif
302   if doro
303    " because the reverse process of compressing changed files back into the tarball is not currently supported
304    setlocal ro
305   endif
307   let w:tarfile= a:fname
308   exe "file tarfile::".fnameescape(fname)
310   " cleanup
311   0d
312   set nomod
314   let &report= repkeep
315 "  call Dret("tar#Read : w:tarfile<".w:tarfile.">")
316 endfun
318 " ---------------------------------------------------------------------
319 " tar#Write: {{{2
320 fun! tar#Write(fname)
321 "  call Dfunc("tar#Write(fname<".a:fname.">) w:tarfile<".w:tarfile."> tblfile_".winnr()."<".s:tblfile_{winnr()}.">")
322   let repkeep= &report
323   set report=10
325   if !exists("g:tar_secure") && a:fname =~ '^\s*-\|\s\+-'
326    redraw!
327    echohl WarningMsg | echo '***warning*** (tar#Write) rejecting tarfile member<'.a:fname.'> because of embedded "-"'
328 "   call Dret('tar#Write : rejecting tarfile member<'.fname.'> because of embedded "-"')
329    return
330   endif
332   " sanity checks
333   if !executable(g:tar_cmd)
334    redraw!
335    echohl Error | echo '***error*** (tar#Browse) "'.g:tar_cmd.'" not available on your system'
336    let &report= repkeep
337 "   call Dret("tar#Write")
338    return
339   endif
340   if !exists("*mkdir")
341    redraw!
342    echohl Error | echo "***error*** (tar#Write) sorry, mkdir() doesn't work on your system" | echohl None
343    let &report= repkeep
344 "   call Dret("tar#Write")
345    return
346   endif
348   let curdir= getcwd()
349   let tmpdir= tempname()
350 "  call Decho("orig tempname<".tmpdir.">")
351   if tmpdir =~ '\.'
352    let tmpdir= substitute(tmpdir,'\.[^.]*$','','e')
353   endif
354 "  call Decho("tmpdir<".tmpdir.">")
355   call mkdir(tmpdir,"p")
357   " attempt to change to the indicated directory
358   try
359    exe "cd ".fnameescape(tmpdir)
360   catch /^Vim\%((\a\+)\)\=:E344/
361    redraw!
362    echohl Error | echo "***error*** (tar#Write) cannot cd to temporary directory" | Echohl None
363    let &report= repkeep
364 "   call Dret("tar#Write")
365    return
366   endtry
367 "  call Decho("current directory now: ".getcwd())
369   " place temporary files under .../_ZIPVIM_/
370   if isdirectory("_ZIPVIM_")
371    call s:Rmdir("_ZIPVIM_")
372   endif
373   call mkdir("_ZIPVIM_")
374   cd _ZIPVIM_
375 "  call Decho("current directory now: ".getcwd())
377   let tarfile = substitute(w:tarfile,'tarfile:\(.\{-}\)::.*$','\1','')
378   let fname   = substitute(w:tarfile,'tarfile:.\{-}::\(.*\)$','\1','')
380   " handle compressed archives
381   if tarfile =~# '\.bz2'
382    call system("bzip2 -d -- ".shellescape(tarfile,0))
383    let tarfile = substitute(tarfile,'\.bz2','','e')
384    let compress= "bzip2 -- ".shellescape(tarfile,0)
385 "   call Decho("compress<".compress.">")
386   elseif tarfile =~# '\.gz'
387    call system("gzip -d -- ".shellescape(tarfile,0))
388    let tarfile = substitute(tarfile,'\.gz','','e')
389    let compress= "gzip -- ".shellescape(tarfile,0)
390 "   call Decho("compress<".compress.">")
391   elseif tarfile =~# '\.lzma'
392    call system("lzma -d -- ".shellescape(tarfile,0))
393    let tarfile = substitute(tarfile,'\.lzma','','e')
394    let compress= "lzma -- ".shellescape(tarfile,0)
395 "   call Decho("compress<".compress.">")
396   elseif tarfile =~# '\.tgz'
397    call system("gzip -d -- ".shellescape(tarfile,0))
398    let tarfile = substitute(tarfile,'\.tgz','.tar','e')
399    let compress= "gzip -- ".shellescape(tarfile,0)
400    let tgz     = 1
401 "   call Decho("compress<".compress.">")
402   endif
403 "  call Decho("tarfile<".tarfile.">")
405   if v:shell_error != 0
406    redraw!
407    echohl Error | echo "***error*** (tar#Write) sorry, unable to update ".tarfile." with ".fname | echohl None
408   else
410 "   call Decho("tarfile<".tarfile."> fname<".fname.">")
412    if fname =~ '/'
413     let dirpath = substitute(fname,'/[^/]\+$','','e')
414     if executable("cygpath")
415      let dirpath = substitute(system("cygpath ".shellescape(dirpath, 0)),'\n','','e')
416     endif
417     call mkdir(dirpath,"p")
418    endif
419    if tarfile !~ '/'
420     let tarfile= curdir.'/'.tarfile
421    endif
422    if tarfile =~ '^\s*-'
423     " A file name starting with a dash may be taken as an option.  Prepend ./ to avoid that.
424     let tarfile = substitute(tarfile, '-', './-', '')
425    endif
426 "   call Decho("tarfile<".tarfile."> fname<".fname.">")
428    if exists("g:tar_secure")
429     let tar_secure= " -- "
430    else
431     let tar_secure= " "
432    endif
433    exe "w! ".fnameescape(fname)
434    if executable("cygpath")
435     let tarfile = substitute(system("cygpath ".shellescape(tarfile,0)),'\n','','e')
436    endif
438    " delete old file from tarfile
439 "   call Decho("system(".g:tar_cmd." --delete -f ".shellescape(tarfile,0)." -- ".shellescape(fname,0).")")
440    call system(g:tar_cmd." --delete -f ".shellescape(tarfile,0).tar_secure.shellescape(fname,0))
441    if v:shell_error != 0
442     redraw!
443     echohl Error | echo "***error*** (tar#Write) sorry, unable to update ".fnameescape(tarfile)." with ".fnameescape(fname) | echohl None
444    else
446     " update tarfile with new file 
447 "    call Decho(g:tar_cmd." -".g:tar_writeoptions." ".shellescape(tarfile,0).tar_secure.shellescape(fname,0))
448     call system(g:tar_cmd." -".g:tar_writeoptions." ".shellescape(tarfile,0).tar_secure.shellescape(fname,0))
449     if v:shell_error != 0
450      redraw!
451      echohl Error | echo "***error*** (tar#Write) sorry, unable to update ".fnameescape(tarfile)." with ".fnameescape(fname) | echohl None
452     elseif exists("compress")
453 "     call Decho("call system(".compress.")")
454      call system(compress)
455      if exists("tgz")
456 "      call Decho("rename(".tarfile.".gz,".substitute(tarfile,'\.tar$','.tgz','e').")")
457       call rename(tarfile.".gz",substitute(tarfile,'\.tar$','.tgz','e'))
458      endif
459     endif
460    endif
462    " support writing tarfiles across a network
463    if s:tblfile_{winnr()} =~ '^\a\+://'
464 "    call Decho("handle writing <".tarfile."> across network to <".s:tblfile_{winnr()}.">")
465     let tblfile= s:tblfile_{winnr()}
466     1split|enew
467     let binkeep= &l:binary
468     let eikeep = &ei
469     set binary ei=all
470     exe "e! ".fnameescape(tarfile)
471     call netrw#NetWrite(tblfile)
472     let &ei       = eikeep
473     let &l:binary = binkeep
474     q!
475     unlet s:tblfile_{winnr()}
476    endif
477   endif
478   
479   " cleanup and restore current directory
480   cd ..
481   call s:Rmdir("_ZIPVIM_")
482   exe "cd ".fnameescape(curdir)
483   setlocal nomod
485   let &report= repkeep
486 "  call Dret("tar#Write")
487 endfun
489 " ---------------------------------------------------------------------
490 " s:Rmdir: {{{2
491 fun! s:Rmdir(fname)
492 "  call Dfunc("Rmdir(fname<".a:fname.">)")
493   if has("unix")
494    call system("/bin/rm -rf -- ".shellescape(a:fname,0))
495   elseif has("win32") || has("win95") || has("win64") || has("win16")
496    if &shell =~? "sh$"
497     call system("/bin/rm -rf -- ".shellescape(a:fname,0))
498    else
499     call system("del /S ".shellescape(a:fname,0))
500    endif
501   endif
502 "  call Dret("Rmdir")
503 endfun
505 " ---------------------------------------------------------------------
506 " tar#Vimuntar: installs a tarball in the user's .vim / vimfiles directory {{{2
507 fun! tar#Vimuntar(...)
508 "  call Dfunc("tar#Vimuntar() a:0=".a:0." a:1<".(exists("a:1")? a:1 : "-n/a-").">")
509   let tarball = expand("%")
510 "  call Decho("tarball<".tarball.">")
511   let tarbase = substitute(tarball,'\..*$','','')
512 "  call Decho("tarbase<".tarbase.">")
513   let tarhome = expand("%:p")
514   if has("win32") || has("win95") || has("win64") || has("win16")
515    let tarhome= substitute(tarhome,'\\','/','g')
516   endif
517   let tarhome= substitute(tarhome,'/[^/]*$','','')
518 "  call Decho("tarhome<".tarhome.">")
519   let tartail = expand("%:t")
520 "  call Decho("tartail<".tartail.">")
521   let curdir  = getcwd()
522 "  call Decho("curdir <".curdir.">")
523   " set up vimhome
524   if a:0 > 0 && a:1 != ""
525    let vimhome= a:1
526   else
527    let vimhome= vimball#VimballHome()
528   endif
529 "  call Decho("vimhome<".vimhome.">")
531 "  call Decho("curdir<".curdir."> vimhome<".vimhome.">")
532   if simplify(curdir) != simplify(vimhome)
533    " copy (possibly compressed) tarball to .vim/vimfiles
534 "   call Decho(netrw#WinPath(g:tar_copycmd)." ".shellescape(tartail)." ".shellescape(vimhome))
535    call system(netrw#WinPath(g:tar_copycmd)." ".shellescape(tartail)." ".shellescape(vimhome))
536 "   call Decho("exe cd ".fnameescape(vimhome))
537    exe "cd ".fnameescape(vimhome)
538   endif
539 "  call Decho("getcwd<".getcwd().">")
541   " if necessary, decompress the tarball; then, extract it
542   if tartail =~ '\.tgz'
543    if executable("gunzip")
544     silent exe "!gunzip ".shellescape(tartail)
545    elseif executable("gzip")
546     silent exe "!gzip -d ".shellescape(tartail)
547    else
548     echoerr "unable to decompress<".tartail."> on this sytem"
549     if simplify(curdir) != simplify(tarhome)
550      " remove decompressed tarball, restore directory
551 "     call Decho("delete(".tartail.".tar)")
552      call delete(tartail.".tar")
553 "     call Decho("exe cd ".fnameescape(curdir))
554      exe "cd ".fnameescape(curdir)
555     endif
556 "    call Dret("tar#Vimuntar")
557     return
558    endif
559   else
560    call vimball#Decompress(tartail,0)
561   endif
562   let extractcmd= netrw#WinPath(g:tar_extractcmd)
563 "  call Decho("system(".extractcmd." ".shellescape(tarbase.".tar").")")
564   call system(extractcmd." ".shellescape(tarbase.".tar"))
566   " set up help
567   if filereadable("doc/".tarbase.".txt")
568 "   call Decho("exe helptags ".getcwd()."/doc")
569    exe "helptags ".getcwd()."/doc"
570   endif
572   if simplify(tarhome) != simplify(vimhome)
573    " remove decompressed tarball, restore directory
574    call delete(vimhome."/".tarbase.".tar")
575    exe "cd ".fnameescape(curdir)
576   endif
578 "  call Dret("tar#Vimuntar")
579 endfun
581 " =====================================================================
582 " Modelines And Restoration: {{{1
583 let &cpo= s:keepcpo
584 unlet s:keepcpo
585 " vim:ts=8 fdm=marker