Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(shim): Fix shim when app path has white spaces #4734

Merged
merged 3 commits into from
Feb 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,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-checkup:** Skip 'check_windows_defender' when have not admin privileges ([#4699](https://github.com/ScoopInstaller/Scoop/issues/4699))
Expand Down
6 changes: 2 additions & 4 deletions lib/core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,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 @@ -644,11 +644,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