Skip to content

Commit

Permalink
fix(shim): Fix shim when app path has white spaces (ScoopInstaller#4734)
Browse files Browse the repository at this point in the history
  • Loading branch information
niheaven authored Feb 26, 2022
1 parent e4580dd commit 9024ee4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
- **shim:** Fix PS1 shim error when in different drive in PS7 ([#4614](https://github.com/ScoopInstaller/Scoop/issues/4614))
- **shim:** Fix `sh` shim error in WSL ([#4637](https://github.com/ScoopInstaller/Scoop/issues/4637))
- **shim:** Use `-file` instead of `-command` in ps1 script shims ([#4721](https://github.com/ScoopInstaller/Scoop/issues/4721))
- **shim:** Fix exe shim when app path has white spaces ([#4734](https://github.com/ScoopInstaller/Scoop/issues/4734))
- **versions:** Fix wrong version number when only one version dir ([#4679](https://github.com/ScoopInstaller/Scoop/issues/4679))
- **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))
- **scoop-alias:** Fix alias initialization ([#4737](https://github.com/ScoopInstaller/Scoop/issues/4737))
Expand Down
6 changes: 2 additions & 4 deletions lib/core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ function shim($path, $global, $name, $arg) {
# for programs with no awareness of any shell
warn_on_overwrite "$shim.shim" $path
Copy-Item (get_shim_path) "$shim.exe" -Force
Write-Output "path = $resolved_path" | Out-File "$shim.shim" -Encoding ASCII
Write-Output "path = `"$resolved_path`"" | Out-File "$shim.shim" -Encoding ASCII
if ($arg) {
Write-Output "args = $arg" | Out-File "$shim.shim" -Encoding ASCII -Append
}
Expand Down Expand Up @@ -650,11 +650,9 @@ function shim($path, $global, $name, $arg) {
"exit `$LASTEXITCODE"
)
} else {
# Setting PSScriptRoot in Shim if it is not defined, so the shim doesn't break in PowerShell 2.0
@(
"# $resolved_path",
"if (!(Test-Path Variable:PSScriptRoot)) { `$PSScriptRoot = Split-Path `$MyInvocation.MyCommand.Path -Parent }",
"`$path = Join-Path `"`$PSScriptRoot`" `"$relative_path`"",
"`$path = Join-Path `$PSScriptRoot `"$relative_path`"",
"if (`$MyInvocation.ExpectingInput) { `$input | & `$path $arg @args } else { & `$path $arg @args }",
"exit `$LASTEXITCODE"
)
Expand Down

0 comments on commit 9024ee4

Please sign in to comment.