diff --git a/CHANGELOG.md b/CHANGELOG.md index 356486b5..bdfc332d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lib/core.ps1 b/lib/core.ps1 index eeaa2c9a..c271ce8f 100644 --- a/lib/core.ps1 +++ b/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"