Skip to content
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,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))
- **shim:** Fix exe shim when app path has white spaces ([#4734](https://github.com/ScoopInstaller/Scoop/issues/4734), [#4780](https://github.com/ScoopInstaller/Scoop/issues/4780))
- **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
2 changes: 1 addition & 1 deletion libexec/scoop-shim.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function Get-ShimPath($ShimName, $Global) {
function Get-ShimTarget($ShimPath) {
if ($ShimPath) {
$shimTarget = if ($ShimPath.EndsWith('.shim')) {
(Get-Content -Path $ShimPath | Select-Object -First 1).Replace('path = ', '')
(Get-Content -Path $ShimPath | Select-Object -First 1).Replace('path = ', '').Replace('"', '')
} else {
((Select-String -Path $ShimPath -Pattern '^(?:@rem|#)\s*(.*)$').Matches.Groups | Select-Object -Index 1).Value
}
Expand Down
30 changes: 17 additions & 13 deletions libexec/scoop-which.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,44 @@ param($command)

reset_aliases

if(!$command) { 'ERROR: <command> missing'; my_usage; exit 1 }
if (!$command) {
'ERROR: <command> missing'
my_usage
exit 1
}

try {
$gcm = Get-Command "$command" -ea stop
$gcm = Get-Command "$command" -ErrorAction Stop
} catch {
abort "'$command' not found" 3
}

$path = "$($gcm.path)"
$usershims = "$(resolve-path $(shimdir $false))"
$path = $gcm.Path
$usershims = Convert-Path (shimdir $false)
$globalshims = fullpath (shimdir $true) # don't resolve: may not exist

if($path -like "$usershims*" -or $path -like "$globalshims*") {
$exepath = if ($path.endswith(".exe") -or $path.endswith(".shim")) {
(Get-Content ($path -replace '\.exe$', '.shim') | Select-Object -First 1).replace('path = ', '')
if ($path -like "$usershims*" -or $path -like "$globalshims*") {
$exepath = if ($path.EndsWith('.exe') -or $path.EndsWith('.shim')) {
(Get-Content ($path -replace '\.exe$', '.shim') | Select-Object -First 1).Replace('path = ', '').Replace('"', '')
} else {
((Select-String -Path $path -Pattern '^(?:@rem|#)\s*(.*)$').Matches.Groups | Select-Object -Index 1).Value
}
if (!$exepath) {
$exepath = ((Select-String -Path $path -Pattern '[''"]([^@&]*?)[''"]' -AllMatches).Matches.Groups | Select-Object -Last 1).Value
}

if(![system.io.path]::ispathrooted($exepath)) {
if (![System.IO.Path]::IsPathRooted($exepath)) {
# Expand relative path
$exepath = resolve-path (join-path (split-path $path) $exepath)
$exepath = Convert-Path $exepath
}

friendly_path $exepath
} elseif($gcm.commandtype -eq 'Application') {
} elseif ($gcm.CommandType -eq 'Application') {
$gcm.Source
} elseif($gcm.commandtype -eq 'Alias') {
scoop which $gcm.resolvedcommandname
} elseif ($gcm.CommandType -eq 'Alias') {
scoop which $gcm.ResolvedCommandName
} else {
[console]::error.writeline("Not a scoop shim.")
Write-Host 'Not a scoop shim.'
$path
exit 2
}
Expand Down