Skip to content

Commit 9024ee4

Browse files
authored
fix(shim): Fix shim when app path has white spaces (#4734)
1 parent e4580dd commit 9024ee4

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
- **shim:** Fix PS1 shim error when in different drive in PS7 ([#4614](https://github.com/ScoopInstaller/Scoop/issues/4614))
3333
- **shim:** Fix `sh` shim error in WSL ([#4637](https://github.com/ScoopInstaller/Scoop/issues/4637))
3434
- **shim:** Use `-file` instead of `-command` in ps1 script shims ([#4721](https://github.com/ScoopInstaller/Scoop/issues/4721))
35+
- **shim:** Fix exe shim when app path has white spaces ([#4734](https://github.com/ScoopInstaller/Scoop/issues/4734))
3536
- **versions:** Fix wrong version number when only one version dir ([#4679](https://github.com/ScoopInstaller/Scoop/issues/4679))
3637
- **versions:** Get current version from failed installation if possible ([#4720](https://github.com/ScoopInstaller/Scoop/issues/4720), [#4725](https://github.com/ScoopInstaller/Scoop/issues/4725))
3738
- **scoop-alias:** Fix alias initialization ([#4737](https://github.com/ScoopInstaller/Scoop/issues/4737))

lib/core.ps1

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ function shim($path, $global, $name, $arg) {
621621
# for programs with no awareness of any shell
622622
warn_on_overwrite "$shim.shim" $path
623623
Copy-Item (get_shim_path) "$shim.exe" -Force
624-
Write-Output "path = $resolved_path" | Out-File "$shim.shim" -Encoding ASCII
624+
Write-Output "path = `"$resolved_path`"" | Out-File "$shim.shim" -Encoding ASCII
625625
if ($arg) {
626626
Write-Output "args = $arg" | Out-File "$shim.shim" -Encoding ASCII -Append
627627
}
@@ -650,11 +650,9 @@ function shim($path, $global, $name, $arg) {
650650
"exit `$LASTEXITCODE"
651651
)
652652
} else {
653-
# Setting PSScriptRoot in Shim if it is not defined, so the shim doesn't break in PowerShell 2.0
654653
@(
655654
"# $resolved_path",
656-
"if (!(Test-Path Variable:PSScriptRoot)) { `$PSScriptRoot = Split-Path `$MyInvocation.MyCommand.Path -Parent }",
657-
"`$path = Join-Path `"`$PSScriptRoot`" `"$relative_path`"",
655+
"`$path = Join-Path `$PSScriptRoot `"$relative_path`"",
658656
"if (`$MyInvocation.ExpectingInput) { `$input | & `$path $arg @args } else { & `$path $arg @args }",
659657
"exit `$LASTEXITCODE"
660658
)

0 commit comments

Comments
 (0)