Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use noninteractive powershell #1627

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions autoload/firenvim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -947,8 +947,9 @@ function! firenvim#install(...) abort
echo 'Creating registry key for ' . l:name . '. This may take a while. Script: ' . l:ps1_path
call s:maybe_execute('writefile', split(l:ps1_content, "\n"), l:ps1_path)
call s:maybe_execute('setfperm', l:ps1_path, 'rwx------')
let l:o = ''
try
let o = s:maybe_execute('system', ['powershell.exe', '-NonInteractive', '-Command', '-'], readfile(l:ps1_path))
let l:o = s:maybe_execute('system', ['powershell.exe', '-NonInteractive', '-Command', '-'], readfile(l:ps1_path))
catch /powershell.exe' is not executable/
let l:failure = v:true
let l:msg = 'Error: Firenvim could not find powershell.exe'
Expand All @@ -957,7 +958,7 @@ function! firenvim#install(...) abort
if s:is_wsl
let l:msg += ' from WSL'
try
let o = s:maybe_execute('system', ['/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe', '-Command', '-'], readfile(l:ps1_path))
let l:o = s:maybe_execute('system', ['/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe', '-NonInteractive', '-Command', '-'], readfile(l:ps1_path))
let l:failure = v:false
catch /powershell.exe' is not executable/
let l:failure = v:true
Expand All @@ -971,7 +972,7 @@ function! firenvim#install(...) abort
endtry

if v:shell_error
echo o
echo l:o
endif

echo 'Created registry key for ' . l:name . '.'
Expand Down Expand Up @@ -1022,9 +1023,28 @@ function! firenvim#uninstall() abort
if has('win32') || s:is_wsl
echo 'Removing registry key for ' . l:name . '. This may take a while.'
let l:ps1_content = 'Remove-Item -Path "' . l:cur_browser['registry_key'] . '" -Recurse'
let o = system(['powershell.exe', '-NonInteractive', '-Command', '-'], [l:ps1_content])
let l:o = ''
try
let l:o = s:maybe_execute('system', ['powershell.exe', '-NonInteractive', '-Command', '-'], [l:ps1_content])
catch /powershell.exe' is not executable/
let l:failure = v:true
let l:msg = 'Error: Firenvim could not find powershell.exe'
" If the failure happened on wsl, try to use
" an absolute path
if s:is_wsl
let l:msg += ' from WSL'
try
let l:o = s:maybe_execute('system', ['/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe', '-NonInteractive', '-Command', '-'], [l:ps1_content])
let l:failure = v:false
catch /powershell.exe' is not executable/
let l:failure = v:true
endtry
endif
let l:msg += ' on your system. Please report this issue.'
endtry

if v:shell_error
echo o
echo l:o
endif
echo 'Removed registry key for ' . l:name . '.'
endif
Expand Down
Loading