fix(core): Use correct path in 'bash' (#6006)

This commit is contained in:
Hsiao-nan Cheung
2024-06-11 11:03:35 +08:00
committed by GitHub
parent d20819e147
commit a9ca75c0cd
2 changed files with 16 additions and 7 deletions

View File

@@ -18,7 +18,8 @@
- **scoop-info:** Fix download size estimating ([#5958](https://github.com/ScoopInstaller/Scoop/issues/5958))
- **decompress:** Match `extract_dir`/`extract_to` and archives ([#5983](https://github.com/ScoopInstaller/Scoop/issues/5983))
- **checkver:** Correct variable 'regex' to 'regexp' ([#5993](https://github.com/ScoopInstaller/Scoop/issues/5993))
- **core:** Search for Git executable instead of any cmdlet ([#5998](https://github.com/ScoopInstaller/Scoop/pull/5998))
- **core:** Search for Git executable instead of any cmdlet ([#5998](https://github.com/ScoopInstaller/Scoop/issues/5998))
- **core:** Use correct path in 'bash' ([#6006](https://github.com/ScoopInstaller/Scoop/issues/6006))
### Code Refactoring

View File

@@ -1041,11 +1041,11 @@ function shim($path, $global, $name, $arg) {
@(
"#!/bin/sh",
"# $resolved_path",
"if [ `$(echo `$WSL_DISTRO_NAME) ]",
"if [ `$WSL_INTEROP ]",
'then',
" cd `$(wslpath -u '$(Split-Path $resolved_path -Parent)')",
'else',
" cd `"$((Split-Path $resolved_path -Parent).Replace('\', '/'))`"",
" cd `$(cygpath -u '$(Split-Path $resolved_path -Parent)')",
'fi',
"java.exe -jar `"$resolved_path`" $arg `"$@`""
) -join "`n" | Out-UTF8File $shim -NoNewLine
@@ -1058,7 +1058,7 @@ function shim($path, $global, $name, $arg) {
warn_on_overwrite $shim $path
@(
"#!/bin/sh",
'#!/bin/sh',
"# $resolved_path",
"python.exe `"$resolved_path`" $arg `"$@`""
) -join "`n" | Out-UTF8File $shim -NoNewLine
@@ -1066,14 +1066,22 @@ function shim($path, $global, $name, $arg) {
warn_on_overwrite "$shim.cmd" $path
@(
"@rem $resolved_path",
"@bash `"$resolved_path`" $arg %*"
"@bash `"`$(wslpath -u '$resolved_path')`" $arg %* 2>nul",
'@if %errorlevel% neq 0 (',
" @bash `"`$(cygpath -u '$resolved_path')`" $arg %* 2>nul",
')'
) -join "`r`n" | Out-UTF8File "$shim.cmd"
warn_on_overwrite $shim $path
@(
"#!/bin/sh",
'#!/bin/sh',
"# $resolved_path",
"`"$resolved_path`" $arg `"$@`""
"if [ `$WSL_INTEROP ]",
'then',
" `"`$(wslpath -u '$resolved_path')`" $arg `"$@`"",
'else',
" `"`$(cygpath -u '$resolved_path')`" $arg `"$@`"",
'fi'
) -join "`n" | Out-UTF8File $shim -NoNewLine
}
}