Fix breakage to 'PlugUpgrade' under Windows PowerShell. (#1331)

Commit 09b7c0e has caused this command to emit an error during its
cleanup when run on Windows with 'shell' set to PowerShell.

The cause of the failure is that the cleanup logic passes the command
string 'rmdir /s /q' to `s:system()` (within `s:rm_rf()`). Before the
commit at fault, this command would be written to a batch file and
executed by 'cmd.exe'. After the commit, it is passed directly to
PowerShell for execution, where 'rmdir' is an alias for 'Remove-Item'
and does not support '/s' and '/q' flags.
This commit is contained in:
tiamat18
2026-05-22 03:21:46 -04:00
committed by GitHub
parent d7db1b637c
commit e216852799

View File

@@ -2469,9 +2469,11 @@ endfunction
function! s:rm_rf(dir)
if isdirectory(a:dir)
return s:system(s:is_win
\ ? 'rmdir /S /Q '.plug#shellescape(a:dir)
\ : ['rm', '-rf', a:dir])
return s:system(!s:is_win
\ ? ['rm', '-rf', a:dir]
\ : s:is_powershell(&shell)
\ ? ['Remove-Item', '-Recurse', '-Force', a:dir]
\ : 'rmdir /S /Q '.plug#shellescape(a:dir))
endif
endfunction