]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
runtime(getscript): CI: failure on powershell
authorChristian Brabandt <cb@256bit.org>
Sun, 11 May 2025 16:30:24 +0000 (18:30 +0200)
committerChristian Brabandt <cb@256bit.org>
Sun, 11 May 2025 16:30:24 +0000 (18:30 +0200)
Problem:  The CheckVimScriptURL() function does not work properly on
          pwershell. Most likely this is because curl is aliased to
          Invoke-WebRequest on Powershell and redirection seems to work
          slightly different
Solution: Disable CheckVimScriptURL() on Powershell and then simplify
          the curl download logic

Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/autoload/getscript.vim

index 88d7a3a0e61c933d2833f9dea64010082244b05f..1e3b5b39d680bfb658a9a606438bc1d945c760f2 100644 (file)
@@ -606,40 +606,24 @@ endfun
 " Check status code of scriptaddr and downloadaddr
 " return v:true if the script is downloadable or v:false in case of errors
 fun CheckVimScriptURL(script_id, src_id)
-  if !executable('curl')
+  " doesn't work with powershell
+  if !executable('curl') || &shell =~? 'pwsh\|powershell'
     return v:true
   endif
   let output = has("win32") ? ' -o NUL ' : ' -o /dev/null '
 
-  " Handle PowerShell differently
-  if &shell =~? '\<pwsh\>\|\<powershell\>'
-    " For PowerShell, use direct command output
-    let script_url = g:GetLatestVimScripts_scriptaddr . a:script_id
-    let script_cmd = 'curl -s -I -w "%{http_code}"' . output . shellescape(script_url)
-    let script_status = system(script_cmd)
-    let script_status = substitute(script_status, '\n$', '', '')
-
-    let download_url = g:GetLatestVimScripts_downloadaddr . a:src_id
-    let download_cmd = 'curl -s -I -w "%{http_code}"' . output . shellescape(download_url)
-    let download_status = system(download_cmd)
-    let download_status = substitute(download_status, '\n$', '', '')
-  else
-    " For other shells, use temporary files
-    let temp_script = tempname()
-    let temp_download = tempname()
-
-    let script_url = g:GetLatestVimScripts_scriptaddr . a:script_id
-    let script_cmd = 'curl -s -I -w "%{http_code}"' . output . shellescape(script_url) . ' >' . shellescape(temp_script)
-    call system(script_cmd)
-    let script_status = readfile(temp_script, 'b')[0]
-    call delete(temp_script)
-
-    let download_url = g:GetLatestVimScripts_downloadaddr . a:src_id
-    let download_cmd = 'curl -s -I -w "%{http_code}"' . output . shellescape(download_url) . ' >' . shellescape(temp_download)
-    call system(download_cmd)
-    let download_status = readfile(temp_download, 'b')[0]
-    call delete(temp_download)
-  endif
+  let temp = tempname()
+  defer delete(temp)
+  let script_url = g:GetLatestVimScripts_scriptaddr . a:script_id
+  let download_url = g:GetLatestVimScripts_downloadaddr . a:src_id
+
+  let script_cmd = 'curl -s -I -w "%{http_code}"' . output . shellescape(script_url) . ' >' . shellescape(temp)
+  call system(script_cmd)
+  let script_status = readfile(temp, 'b')[0]
+
+  let download_cmd = 'curl -s -I -w "%{http_code}"' . output . shellescape(download_url) . ' >' . shellescape(temp)
+  call system(download_cmd)
+  let download_status = readfile(temp, 'b')[0]
 
   if script_status !=# '200'
     let s:message += [ printf('Error: Failed to reach script: %s', a:script_id) ]
@@ -651,7 +635,7 @@ fun CheckVimScriptURL(script_id, src_id)
     return v:false
   endif
   return v:true
-endfunction
+endfun
 
 " ---------------------------------------------------------------------
 " Restore Options: {{{1