From b8ec43a4a7b4437194ff188e2faa25bf20417272 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 16 Feb 2026 10:29:20 +0800 Subject: [PATCH] vim-patch:abac1c1: runtime(zip): use system() instead of :! - ':!' is not stable, so use system() to get more consistent behaviour. - Only warns when using 'pwsh'. - Remove trailing spaces. closes: vim/vim#19370 https://github.com/vim/vim/commit/abac1c1aa67d96313a9cfd086e2267f1c684e740 Co-authored-by: Mao-Yining Co-Authored-by: @lxhillwind --- runtime/autoload/zip.vim | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/runtime/autoload/zip.vim b/runtime/autoload/zip.vim index e3326b0dd0..a86bd4ee10 100644 --- a/runtime/autoload/zip.vim +++ b/runtime/autoload/zip.vim @@ -1,4 +1,4 @@ - " zip.vim: Handles browsing zipfiles +" zip.vim: Handles browsing zipfiles " AUTOLOAD PORTION " Date: 2024 Aug 21 " Version: 34 @@ -18,6 +18,7 @@ " 2025 Jul 12 by Vim Project: drop ../ on write to prevent path traversal attacks " 2025 Sep 22 by Vim Project: support PowerShell Core " 2025 Dec 20 by Vim Project: use :lcd instead of :cd +" 2026 Feb 08 by Vim Project: use system() instead of :! " License: Vim License (see vim's :help license) " Copyright: Copyright (C) 2005-2019 Charles E. Campbell {{{1 " Permission is hereby granted to use and distribute this code, @@ -139,7 +140,7 @@ endfunction function! s:ZipReadPS(zipfile, fname, tempfile) " Read a filename within a zipped file to a temporary file. " Equivalent to `unzip -p -- zipfile fname > tempfile` - if a:fname =~ '/' + if &shell =~ 'pwsh' call s:Mess('WarningMsg', "***warning*** PowerShell can display, but cannot update, files in archive subfolders") endif let cmds = [ @@ -335,7 +336,8 @@ fun! zip#Read(fname,mode) let temp = tempname() let fn = expand('%:p') - let gnu_cmd = 'sil !' . g:zip_unzipcmd . ' -p -- ' . s:Escape(zipfile, 1) . ' ' . s:Escape(fname, 1) . ' > ' . s:Escape(temp, 1) + let gnu_cmd = g:zip_unzipcmd . ' -p -- ' . s:Escape(zipfile, 0) . ' ' . s:Escape(fname, 0) . ' > ' . s:Escape(temp, 0) + let gnu_cmd = 'call system(''' . substitute(gnu_cmd, "'", "''", 'g') . ''')' let ps_cmd = 'sil !' . s:ZipReadPS(zipfile, fname, temp) call s:TryExecGnuFallBackToPs(g:zip_unzipcmd, gnu_cmd, ps_cmd) @@ -391,7 +393,7 @@ fun! zip#Write(fname) let fname = substitute(a:fname,'^.\{-}zipfile://.\{-}::\([^\\].*\)$','\1','') endif if fname =~ '^[.]\{1,2}/' - let gnu_cmd = g:zip_zipcmd . ' -d ' . s:Escape(fnamemodify(zipfile,":p"),0) . ' ' . s:Escape(fname,0) + let gnu_cmd = g:zip_zipcmd . ' -d ' . s:Escape(fnamemodify(zipfile,":p"),0) . ' ' . s:Escape(fname,0) let gnu_cmd = 'call system(''' . substitute(gnu_cmd, "'", "''", 'g') . ''')' let ps_cmd = $"call system({s:Escape(s:ZipDeleteFilePS(zipfile, fname), 1)})" call s:TryExecGnuFallBackToPs(g:zip_zipcmd, gnu_cmd, ps_cmd) @@ -420,7 +422,7 @@ fun! zip#Write(fname) let fname = substitute(fname, '[', '[[]', 'g') endif - let gnu_cmd = g:zip_zipcmd . ' -u '. s:Escape(fnamemodify(zipfile,":p"),0) . ' ' . s:Escape(fname,0) + let gnu_cmd = g:zip_zipcmd . ' -u '. s:Escape(fnamemodify(zipfile,":p"),0) . ' ' . s:Escape(fname,0) let gnu_cmd = 'call system(''' . substitute(gnu_cmd, "'", "''", 'g') . ''')' let ps_cmd = s:ZipUpdatePS(s:Escape(fnamemodify(zipfile, ':p'), 0), s:Escape(fname, 0)) let ps_cmd = 'call system(''' . substitute(ps_cmd, "'", "''", 'g') . ''')'