Skip to content

Commit

Permalink
fix(scoop): Pass CLI arguments as string objects (ScoopInstaller#4931)
Browse files Browse the repository at this point in the history
Co-authored-by: Hsiao-nan Cheung <niheaven@gmail.com>
  • Loading branch information
L. Yeung and niheaven authored May 17, 2022
1 parent 47d7f76 commit ac2fb38
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- **bucket:** Don't check remote URL of non-git buckets ([#4923](https://github.com/ScoopInstaller/Scoop/issues/4923))
- **bucket:** Don't write message OK before bucket is cloned ([#4925](https://github.com/ScoopInstaller/Scoop/issues/4925))
- **shim:** Remove character replacement in .cmd -> .ps1 shims ([#4914](https://github.com/ScoopInstaller/Scoop/issues/4914))
- **scoop:** Pass CLI arguments as string objects ([#4931](https://github.com/ScoopInstaller/Scoop/issues/4931))
- **scoop-info:** Fix error message when manifest is not found ([#4935](https://github.com/ScoopInstaller/Scoop/issues/4935))

### Documentation
Expand Down
29 changes: 13 additions & 16 deletions bin/scoop.ps1
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
#Requires -Version 5
param($SubCommand)

Set-StrictMode -Off

. "$PSScriptRoot\..\lib\core.ps1"
. "$PSScriptRoot\..\lib\buckets.ps1"
. "$PSScriptRoot\..\lib\commands.ps1"
. "$PSScriptRoot\..\lib\help.ps1"

$subCommand = $Args[0]

# for aliases where there's a local function, re-alias so the function takes precedence
$aliases = Get-Alias | Where-Object { $_.Options -notmatch 'ReadOnly|AllScope' } | ForEach-Object { $_.Name }
Get-ChildItem Function: | Where-Object -Property Name -In -Value $aliases | ForEach-Object {
Set-Alias -Name $_.Name -Value Local:$($_.Name) -Scope Script
}

switch ($SubCommand) {
({ $SubCommand -in @($null, '--help', '/?') }) {
if (!$SubCommand -and $Args -eq '-v') {
$SubCommand = '--version'
} else {
exec 'help'
}
switch ($subCommand) {
({ $subCommand -in @($null, '-h', '--help', '/?') }) {
exec 'help'
}
({ $SubCommand -eq '--version' }) {
({ $subCommand -in @('-v', '--version') }) {
Write-Host 'Current Scoop version:'
if ((Test-CommandAvailable git) -and (Test-Path "$PSScriptRoot\..\.git") -and (get_config SCOOP_BRANCH 'master') -ne 'master') {
Invoke-Expression "git -C '$PSScriptRoot\..' --no-pager log --oneline HEAD -n 1"
Expand All @@ -35,22 +31,23 @@ switch ($SubCommand) {

Get-LocalBucket | ForEach-Object {
$bucketLoc = Find-BucketDirectory $_ -Root
if ((Test-Path (Join-Path $bucketLoc '.git')) -and (Test-CommandAvailable git)) {
if ((Test-Path "$bucketLoc\.git") -and (Test-CommandAvailable git)) {
Write-Host "'$_' bucket:"
Invoke-Expression "git -C '$bucketLoc' --no-pager log --oneline HEAD -n 1"
Write-Host ''
}
}
}
({ $SubCommand -in (commands) }) {
if ($Args -in @('-h', '--help', '/?')) {
exec 'help' @($SubCommand)
({ $subCommand -in (commands) }) {
[string[]]$arguments = $Args | Select-Object -Skip 1
if ($null -ne $arguments -and $arguments[0] -in @('-h', '--help', '/?')) {
exec 'help' @($subCommand)
} else {
exec $SubCommand $Args
exec $subCommand $arguments
}
}
default {
"scoop: '$SubCommand' isn't a scoop command. See 'scoop help'."
"scoop: '$subCommand' isn't a scoop command. See 'scoop help'."
exit 1
}
}

0 comments on commit ac2fb38

Please sign in to comment.