vim-patch:3a5b3df7764d (#26956)

runtime(tar): fix a few problems with the tar plugin

From: vim/vim#138331:
  - Updating .tar.zst files was broken. Fixes vim/vim#12639.
  - Extracting files from .tar.zst / .tzs files was also broken and
    works now.
From: vim/vim#12637:
  - Fixes variable assignment and typo
From: vim/vim#8109:
  - Rename .tzs to the more standard .tzst

fixes: vim/vim#12639
fixes: vim/vim#8105
closes: vim/vim#8109
closes: vim/vim#12637
closes: vim/vim#13831

3a5b3df776

Co-authored-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Martin Rys <martin@rys.pw>
Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
Co-authored-by: Carlo Teubner <carlo@cteubner.net>
This commit is contained in:
dundargoc 2024-01-09 23:03:09 +01:00 committed by GitHub
parent beca827212
commit 501cf32357
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 19 deletions

View File

@ -163,9 +163,9 @@ fun! tar#Browse(tarfile)
" call Decho("1: exe silent r! gzip -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - ") " call Decho("1: exe silent r! gzip -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - ")
exe "sil! r! gzip -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - " exe "sil! r! gzip -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
elseif tarfile =~# '\.\(tgz\)$' || tarfile =~# '\.\(tbz\)$' || tarfile =~# '\.\(txz\)$' || tarfile =~# '\.\(tzs\)$' elseif tarfile =~# '\.\(tgz\)$' || tarfile =~# '\.\(tbz\)$' || tarfile =~# '\.\(txz\)$' || tarfile =~# '\.\(tzst\)$'
if has("unix") && executable("file") if has("unix") && executable("file")
let filekind= system("file ".shellescape(tarfile,1)) =~ "bzip2" let filekind= system("file ".shellescape(tarfile,1))
else else
let filekind= "" let filekind= ""
endif endif
@ -192,7 +192,7 @@ fun! tar#Browse(tarfile)
elseif tarfile =~# '\.\(xz\|txz\)$' elseif tarfile =~# '\.\(xz\|txz\)$'
" call Decho("3: exe silent r! xz --decompress --stdout -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - ") " call Decho("3: exe silent r! xz --decompress --stdout -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - ")
exe "sil! r! xz --decompress --stdout -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - " exe "sil! r! xz --decompress --stdout -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
elseif tarfile =~# '\.\(zst\|tzs\)$' elseif tarfile =~# '\.\(zst\|tzst\)$'
exe "sil! r! zstd --decompress --stdout -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - " exe "sil! r! zstd --decompress --stdout -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
else else
if tarfile =~ '^\s*-' if tarfile =~ '^\s*-'
@ -468,9 +468,9 @@ fun! tar#Write(fname)
let compress= "xz -- ".shellescape(tarfile,0) let compress= "xz -- ".shellescape(tarfile,0)
" call Decho("compress<".compress.">") " call Decho("compress<".compress.">")
elseif tarfile =~# '\.zst' elseif tarfile =~# '\.zst'
call system("zstd --decompress -- ".shellescape(tarfile,0)) call system("zstd --decompress --rm -- ".shellescape(tarfile,0))
let tarfile = substitute(tarfile,'\.zst','','e') let tarfile = substitute(tarfile,'\.zst','','e')
let compress= "zstd -- ".shellescape(tarfile,0) let compress= "zstd --rm -- ".shellescape(tarfile,0)
elseif tarfile =~# '\.lzma' elseif tarfile =~# '\.lzma'
call system("lzma -d -- ".shellescape(tarfile,0)) call system("lzma -d -- ".shellescape(tarfile,0))
let tarfile = substitute(tarfile,'\.lzma','','e') let tarfile = substitute(tarfile,'\.lzma','','e')
@ -696,13 +696,13 @@ fun! tar#Extract()
echo "***note*** successfully extracted ".fname echo "***note*** successfully extracted ".fname
endif endif
elseif filereadable(tarbase.".tzs") elseif filereadable(tarbase.".tzst")
let extractcmd= substitute(extractcmd,"-","--zstd","") let extractcmd= substitute(extractcmd,"-","--zstd","")
" call Decho("system(".extractcmd." ".shellescape(tarbase).".tzs ".shellescape(fname).")") " call Decho("system(".extractcmd." ".shellescape(tarbase).".tzst ".shellescape(fname).")")
call system(extractcmd." ".shellescape(tarbase).".txz ".shellescape(fname)) call system(extractcmd." ".shellescape(tarbase).".tzst ".shellescape(fname))
if v:shell_error != 0 if v:shell_error != 0
echohl Error | echo "***error*** ".extractcmd." ".tarbase.".tzs ".fname.": failed!" | echohl NONE echohl Error | echo "***error*** ".extractcmd." ".tarbase.".tzst ".fname.": failed!" | echohl NONE
" call Decho("***error*** ".extractcmd." ".tarbase.".tzs ".fname.": failed!") " call Decho("***error*** ".extractcmd." ".tarbase.".tzst ".fname.": failed!")
else else
echo "***note*** successfully extracted ".fname echo "***note*** successfully extracted ".fname
endif endif
@ -710,7 +710,7 @@ fun! tar#Extract()
elseif filereadable(tarbase.".tar.zst") elseif filereadable(tarbase.".tar.zst")
let extractcmd= substitute(extractcmd,"-","--zstd","") let extractcmd= substitute(extractcmd,"-","--zstd","")
" call Decho("system(".extractcmd." ".shellescape(tarbase).".tar.zst ".shellescape(fname).")") " call Decho("system(".extractcmd." ".shellescape(tarbase).".tar.zst ".shellescape(fname).")")
call system(extractcmd." ".shellescape(tarbase).".tar.xz ".shellescape(fname)) call system(extractcmd." ".shellescape(tarbase).".tar.zst ".shellescape(fname))
if v:shell_error != 0 if v:shell_error != 0
echohl Error | echo "***error*** ".extractcmd." ".tarbase.".tar.zst ".fname.": failed!" | echohl NONE echohl Error | echo "***error*** ".extractcmd." ".tarbase.".tar.zst ".fname.": failed!" | echohl NONE
" call Decho("***error*** ".extractcmd." ".tarbase.".tar.zst ".fname.": failed!") " call Decho("***error*** ".extractcmd." ".tarbase.".tar.zst ".fname.": failed!")

View File

@ -45,7 +45,7 @@ augroup tar
au BufReadCmd *.tar.xz call tar#Browse(expand("<amatch>")) au BufReadCmd *.tar.xz call tar#Browse(expand("<amatch>"))
au BufReadCmd *.txz call tar#Browse(expand("<amatch>")) au BufReadCmd *.txz call tar#Browse(expand("<amatch>"))
au BufReadCmd *.tar.zst call tar#Browse(expand("<amatch>")) au BufReadCmd *.tar.zst call tar#Browse(expand("<amatch>"))
au BufReadCmd *.tzs call tar#Browse(expand("<amatch>")) au BufReadCmd *.tzst call tar#Browse(expand("<amatch>"))
augroup END augroup END
" --------------------------------------------------------------------- " ---------------------------------------------------------------------