fix(scoop): Pass CLI arguments as string objects (#4931)

Co-authored-by: Hsiao-nan Cheung <niheaven@gmail.com>
This commit is contained in:
L. Yeung
2022-05-18 00:06:08 +08:00
committed by GitHub
parent 47d7f76f7c
commit ac2fb38722
2 changed files with 14 additions and 16 deletions

View File

@@ -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

View File

@@ -1,6 +1,4 @@
#Requires -Version 5
param($SubCommand)
Set-StrictMode -Off
. "$PSScriptRoot\..\lib\core.ps1"
@@ -8,21 +6,19 @@ Set-StrictMode -Off
. "$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"
@@ -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
}
}