mirror of
https://github.com/ScoopInstaller/Scoop.git
synced 2025-10-30 06:07:56 +00:00
fix(shim): properly check wslpath/cygpath command first (#6114)
Co-authored-by: Hsiao-nan Cheung <niheaven@gmail.com>
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
- **scoop-download|install|update:** Fallback to default downloader when aria2 fails ([#4292](https://github.com/ScoopInstaller/Scoop/issues/4292))
|
||||
- **decompress**: `Expand-7zipArchive` only delete temp dir / `$extractDir` if it is empty ([#6092](https://github.com/ScoopInstaller/Scoop/issues/6092))
|
||||
- **commands**: Handling broken aliases ([#6141](https://github.com/ScoopInstaller/Scoop/issues/6141))
|
||||
- **shim:** Do not suppress `stderr`, properly check `wslpath`/`cygpath` command first ([#6114](https://github.com/ScoopInstaller/Scoop/pull/6114))
|
||||
|
||||
### Code Refactoring
|
||||
|
||||
|
||||
13
lib/core.ps1
13
lib/core.ps1
@@ -1003,11 +1003,18 @@ function shim($path, $global, $name, $arg) {
|
||||
) -join "`n" | Out-UTF8File $shim -NoNewLine
|
||||
} else {
|
||||
warn_on_overwrite "$shim.cmd" $path
|
||||
$quoted_arg = if ($arg.Count -gt 0) { $arg | ForEach-Object { "`"$_`"" } }
|
||||
@(
|
||||
"@rem $resolved_path",
|
||||
"@bash `"`$(wslpath -u '$resolved_path')`" $arg %* 2>nul",
|
||||
'@if %errorlevel% neq 0 (',
|
||||
" @bash `"`$(cygpath -u '$resolved_path')`" $arg %* 2>nul",
|
||||
'@echo off',
|
||||
'bash -c "command -v wslpath >/dev/null"',
|
||||
'if %errorlevel% equ 0 (',
|
||||
" bash `"`$(wslpath -u '$resolved_path')`" $quoted_arg %*",
|
||||
') else (',
|
||||
" set args=$quoted_arg %*",
|
||||
' setlocal enabledelayedexpansion',
|
||||
' if not "!args!"=="" set args=!args:"=""!',
|
||||
" bash -c `"`$(cygpath -u '$resolved_path') !args!`"",
|
||||
')'
|
||||
) -join "`r`n" | Out-UTF8File "$shim.cmd"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user