runtime(zip): use system() instead of :!
Commit:
https://github.com/vim/vim/commit/abac1c1aa67d96313a9cfd086e2267f1c684e740
Author: Mao-Yining <[email protected]>
Date: Sun Feb 15 16:36:29 2026 +0000
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: #19370
Co-Authored-by: @lxhillwind
Signed-off-by: Mao-Yining <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/runtime/autoload/zip.vim b/runtime/autoload/zip.vim
index 74b0d28fa..263c3555c 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://.\{-}::\([^\].*\)$','
','')
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') . ''')'
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/E1vrfF5-00DjDt-0K%40256bit.org.