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): Add 'Get-CommandPath()' to find git #4913

Merged
merged 8 commits into from
May 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
fix: Return $null if command not found
  • Loading branch information
niheaven committed May 26, 2022
commit 86c22414f0ae2641467843759158e512ec54f74d
2 changes: 1 addition & 1 deletion lib/core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ function Get-CommandPath {
try {
$comm = Get-Command $Command -ErrorAction Stop
} catch {
abort "'$Command' not found" 3
return $null
}
$commandPath = if ($comm.Path -like "$userShims*" -or $comm.Path -like "$globalShims*") {
Get-ShimTarget ($comm.Path -replace '\.exe$', '.shim')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a bin includes both *.ps1 and *.exe shims (like aria2c):

> gcm aria2c -all
...\shims\aria2c.ps1
...\shims\aria2c.exe

The command scoop which aria2c show 'aria2c' not found / not a scoop shim..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new shim system should use only .exe shims, and .ps1 shims are only used for .cmd or bash script.

Try remove all shims except scoop.* and scoop reset *, and this should be fixed.

Expand Down
8 changes: 1 addition & 7 deletions libexec/scoop-which.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,10 @@ if (!$command) {
exit 1
}

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

$path = Get-CommandPath $command

if ($null -eq $path) {
Write-Host 'Not a scoop shim.'
Write-Host "'$command' not found / not a scoop shim."
exit 2
} else {
friendly_path $path
Expand Down