From 691c23330c45e912e1e01f071d03ed640399a14c Mon Sep 17 00:00:00 2001 From: AkariiinMKII <6019344+AkariiinMKII@users.noreply.github.com> Date: Thu, 14 Aug 2025 17:51:19 +0800 Subject: [PATCH 01/11] fix(scoop-download): Fix function `nightly_version` not defined error (#6386) --- CHANGELOG.md | 6 ++++++ libexec/scoop-download.ps1 | 1 + 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0c15ec326..ffe2a7fbf9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## [Unreleased](https://github.com/ScoopInstaller/Scoop/compare/v0.5.3...develop) + +### Bug Fixes + +- **scoop-download**: Fix function `nightly_version` not defined error ([#6386](https://github.com/ScoopInstaller/Scoop/issues/6386)) + ## [v0.5.3](https://github.com/ScoopInstaller/Scoop/compare/v0.5.2...v0.5.3) - 2025-08-11 ### Features diff --git a/libexec/scoop-download.ps1 b/libexec/scoop-download.ps1 index 996cb4e8e6..34a78ea952 100644 --- a/libexec/scoop-download.ps1 +++ b/libexec/scoop-download.ps1 @@ -25,6 +25,7 @@ . "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion' . "$PSScriptRoot\..\lib\manifest.ps1" # 'generate_user_manifest' 'Get-Manifest' . "$PSScriptRoot\..\lib\download.ps1" +. "$PSScriptRoot\..\lib\install.ps1" # 'nightly_version' if (get_config USE_SQLITE_CACHE) { . "$PSScriptRoot\..\lib\database.ps1" } From c9f0728ff7cab879fc0adecad319816c5aded95b Mon Sep 17 00:00:00 2001 From: HUMORCE Date: Wed, 20 Aug 2025 13:59:47 +0800 Subject: [PATCH 02/11] fix(autoupdate): Use origin url to handle urls with fragment in github mode (#6455) --- CHANGELOG.md | 1 + lib/autoupdate.ps1 | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ffe2a7fbf9..279c76d947 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Bug Fixes - **scoop-download**: Fix function `nightly_version` not defined error ([#6386](https://github.com/ScoopInstaller/Scoop/issues/6386)) +- **autoupdate:** Use origin URL to handle URLs with fragment in GitHub mode ([#6455](https://github.com/ScoopInstaller/Scoop/issues/6455)) ## [v0.5.3](https://github.com/ScoopInstaller/Scoop/compare/v0.5.2...v0.5.3) - 2025-08-11 diff --git a/lib/autoupdate.ps1 b/lib/autoupdate.ps1 index 711f2fd6e5..fbc3ebfdee 100644 --- a/lib/autoupdate.ps1 +++ b/lib/autoupdate.ps1 @@ -3,6 +3,8 @@ function format_hash([String] $hash) { $hash = $hash.toLower() + # Workaround for GitHub API: + # `"digest": "sha256:"` if ($hash -like 'sha256:*') { $hash = $hash.Substring(7) # Remove prefix 'sha256:' } @@ -209,13 +211,14 @@ function get_hash_for_app([String] $app, $config, [String] $version, [String] $u $hash = $null $hashmode = $config.mode + $originurl = strip_fragment $url $basename = [System.Web.HttpUtility]::UrlDecode((url_remote_filename($url))) $substitutions = $substitutions.Clone() - $substitutions.Add('$url', (strip_fragment $url)) - $substitutions.Add('$baseurl', (strip_filename (strip_fragment $url)).TrimEnd('/')) + $substitutions.Add('$url', $originurl) + $substitutions.Add('$baseurl', (strip_filename $originurl).TrimEnd('/')) $substitutions.Add('$basename', $basename) - $substitutions.Add('$urlNoExt', (strip_ext (strip_fragment $url))) + $substitutions.Add('$urlNoExt', (strip_ext $originurl)) $substitutions.Add('$basenameNoExt', (strip_ext $basename)) debug $substitutions @@ -297,7 +300,7 @@ function get_hash_for_app([String] $app, $config, [String] $version, [String] $u } 'github' { $hashfile_url = "https://api.github.com/repos/$($matches['owner'])/$($matches['repo'])/releases" - $hash = find_hash_in_json $hashfile_url $substitutions ("$..assets[?(@.browser_download_url == '" + $url + "')].digest") + $hash = find_hash_in_json $hashfile_url $substitutions ("$..assets[?(@.browser_download_url == '" + $originurl + "')].digest") } } From ff38652e0126d8a86b1f935dbb2e69299061e4dc Mon Sep 17 00:00:00 2001 From: z-Fng <54583083+z-Fng@users.noreply.github.com> Date: Thu, 21 Aug 2025 14:18:33 +0800 Subject: [PATCH 03/11] fix(buckets|scoop-info): Switch git log date format to ISO 8601 to avoid locale issues (#6446) --- CHANGELOG.md | 1 + lib/buckets.ps1 | 2 +- libexec/scoop-info.ps1 | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 279c76d947..800b03097c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - **scoop-download**: Fix function `nightly_version` not defined error ([#6386](https://github.com/ScoopInstaller/Scoop/issues/6386)) - **autoupdate:** Use origin URL to handle URLs with fragment in GitHub mode ([#6455](https://github.com/ScoopInstaller/Scoop/issues/6455)) +- **buckets|scoop-info:** Switch git log date format to ISO 8601 to avoid locale issues ([#6446](https://github.com/ScoopInstaller/Scoop/pull/6446)) ## [v0.5.3](https://github.com/ScoopInstaller/Scoop/compare/v0.5.2...v0.5.3) - 2025-08-11 diff --git a/lib/buckets.ps1 b/lib/buckets.ps1 index 87bc02d287..08d6d0bd7e 100644 --- a/lib/buckets.ps1 +++ b/lib/buckets.ps1 @@ -108,7 +108,7 @@ function list_buckets { $path = Find-BucketDirectory $_ -Root if ((Test-Path (Join-Path $path '.git')) -and (Get-Command git -ErrorAction SilentlyContinue)) { $bucket.Source = Invoke-Git -Path $path -ArgumentList @('config', 'remote.origin.url') - $bucket.Updated = Invoke-Git -Path $path -ArgumentList @('log', '--format=%aD', '-n', '1') | Get-Date + $bucket.Updated = Invoke-Git -Path $path -ArgumentList @('log', '--format=%aI', '-n', '1') | Get-Date } else { $bucket.Source = friendly_path $path $bucket.Updated = (Get-Item "$path\bucket" -ErrorAction SilentlyContinue).LastWriteTime diff --git a/libexec/scoop-info.ps1 b/libexec/scoop-info.ps1 index 1322e33a63..1c147e17c0 100644 --- a/libexec/scoop-info.ps1 +++ b/libexec/scoop-info.ps1 @@ -122,7 +122,7 @@ if ($manifest.depends) { if (Test-Path $manifest_file) { if (Get-Command git -ErrorAction Ignore) { - $gitinfo = (Invoke-Git -Path (Split-Path $manifest_file) -ArgumentList @('log', '-1', '-s', '--format=%aD#%an', $manifest_file) 2> $null) -Split '#' + $gitinfo = (Invoke-Git -Path (Split-Path $manifest_file) -ArgumentList @('log', '-1', '-s', '--format=%aI#%an', $manifest_file) 2> $null) -Split '#' } if ($gitinfo) { $item.'Updated at' = $gitinfo[0] | Get-Date From 04b7ce79c7a1395f5db0141bf247a29d92873515 Mon Sep 17 00:00:00 2001 From: z-Fng <54583083+z-Fng@users.noreply.github.com> Date: Wed, 27 Aug 2025 05:46:16 -0400 Subject: [PATCH 04/11] fix(scoop-version): Fix logic error caused by missing brackets (#6463) --- CHANGELOG.md | 5 +++-- bin/scoop.ps1 | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 800b03097c..3795ce5dc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,10 @@ ### Bug Fixes -- **scoop-download**: Fix function `nightly_version` not defined error ([#6386](https://github.com/ScoopInstaller/Scoop/issues/6386)) +- **scoop-download:** Fix function `nightly_version` not defined error ([#6386](https://github.com/ScoopInstaller/Scoop/issues/6386)) - **autoupdate:** Use origin URL to handle URLs with fragment in GitHub mode ([#6455](https://github.com/ScoopInstaller/Scoop/issues/6455)) -- **buckets|scoop-info:** Switch git log date format to ISO 8601 to avoid locale issues ([#6446](https://github.com/ScoopInstaller/Scoop/pull/6446)) +- **buckets|scoop-info:** Switch git log date format to ISO 8601 to avoid locale issues ([#6446](https://github.com/ScoopInstaller/Scoop/issues/6446)) +- **scoop-version:** Fix logic error caused by missing brackets ([#6463](https://github.com/ScoopInstaller/Scoop/issues/6463)) ## [v0.5.3](https://github.com/ScoopInstaller/Scoop/compare/v0.5.2...v0.5.3) - 2025-08-11 diff --git a/bin/scoop.ps1 b/bin/scoop.ps1 index fd2fd41fa7..036a05ba29 100644 --- a/bin/scoop.ps1 +++ b/bin/scoop.ps1 @@ -20,8 +20,8 @@ switch ($subCommand) { } ({ $subCommand -in @('-v', '--version') }) { Write-Host 'Current Scoop version:' - if (Test-GitAvailable -and (Test-Path "$PSScriptRoot\..\.git") -and (get_config SCOOP_BRANCH 'master') -ne 'master') { - Invoke-Git -Path "$PSScriptRoot\.." -ArgumentList @('log', 'HEAD', '-1', '--oneline') + if ((Test-GitAvailable) -and (Test-Path "$PSScriptRoot\..\.git") -and ((get_config SCOOP_BRANCH 'master') -ne 'master')) { + Invoke-Git -Path "$PSScriptRoot\.." -ArgumentList @('--no-pager', 'log', 'HEAD', '-1', '--oneline') } else { $version = Select-String -Pattern '^## \[(v[\d.]+)\].*?([\d-]+)$' -Path "$PSScriptRoot\..\CHANGELOG.md" Write-Host $version.Matches.Groups[1].Value -ForegroundColor Cyan -NoNewline @@ -31,9 +31,9 @@ switch ($subCommand) { Get-LocalBucket | ForEach-Object { $bucketLoc = Find-BucketDirectory $_ -Root - if (Test-GitAvailable -and (Test-Path "$bucketLoc\.git")) { + if ((Test-GitAvailable) -and (Test-Path "$bucketLoc\.git")) { Write-Host "'$_' bucket:" - Invoke-Git -Path $bucketLoc -ArgumentList @('log', 'HEAD', '-1', '--oneline') + Invoke-Git -Path $bucketLoc -ArgumentList @('--no-pager', 'log', 'HEAD', '-1', '--oneline') Write-Host '' } } From 25d35007c64141cb6df25767e92d80f65cfd77a4 Mon Sep 17 00:00:00 2001 From: z-Fng <54583083+z-Fng@users.noreply.github.com> Date: Wed, 24 Sep 2025 14:45:01 +0800 Subject: [PATCH 05/11] fix(core|manifest): Avoid error when searching non-existent 'deprecated' directory (#6471) --- CHANGELOG.md | 1 + lib/core.ps1 | 2 +- lib/manifest.ps1 | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3795ce5dc3..55455b939c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - **autoupdate:** Use origin URL to handle URLs with fragment in GitHub mode ([#6455](https://github.com/ScoopInstaller/Scoop/issues/6455)) - **buckets|scoop-info:** Switch git log date format to ISO 8601 to avoid locale issues ([#6446](https://github.com/ScoopInstaller/Scoop/issues/6446)) - **scoop-version:** Fix logic error caused by missing brackets ([#6463](https://github.com/ScoopInstaller/Scoop/issues/6463)) +- **core|manifest:** Avoid error messages when searching non-existent 'deprecated' directory ([#6471](https://github.com/ScoopInstaller/Scoop/issues/6471)) ## [v0.5.3](https://github.com/ScoopInstaller/Scoop/compare/v0.5.2...v0.5.3) - 2025-08-11 diff --git a/lib/core.ps1 b/lib/core.ps1 index 7ca7d121e2..2b9f8b68af 100644 --- a/lib/core.ps1 +++ b/lib/core.ps1 @@ -555,7 +555,7 @@ function app_status($app, $global) { $status.hold = ($install_info.hold -eq $true) $deprecated_dir = (Find-BucketDirectory -Name $install_info.bucket -Root) + "\deprecated" - $status.deprecated = (Get-ChildItem $deprecated_dir -Filter "$(sanitary_path $app).json" -Recurse).FullName + $status.deprecated = (Get-ChildItem $deprecated_dir -Filter "$(sanitary_path $app).json" -Recurse -ErrorAction Ignore).FullName $manifest = manifest $app $install_info.bucket $install_info.url $status.removed = (!$manifest) diff --git a/lib/manifest.ps1 b/lib/manifest.ps1 index 29c898b6a7..6510dd650c 100644 --- a/lib/manifest.ps1 +++ b/lib/manifest.ps1 @@ -69,7 +69,7 @@ function Get-Manifest($app) { $manifest = manifest $app $bucket if (!$manifest) { $deprecated_dir = (Find-BucketDirectory -Name $bucket -Root) + '\deprecated' - $manifest = parse_json (Get-ChildItem $deprecated_dir -Filter "$(sanitary_path $app).json" -Recurse).FullName + $manifest = parse_json (Get-ChildItem $deprecated_dir -Filter "$(sanitary_path $app).json" -Recurse -ErrorAction Ignore).FullName } } } From b592b38abd078b83ee6143f2b120c3cce169c8b2 Mon Sep 17 00:00:00 2001 From: z-Fng <54583083+z-Fng@users.noreply.github.com> Date: Wed, 24 Sep 2025 16:52:03 +0800 Subject: [PATCH 06/11] feat(install): Add separator at the end of notes, highlight suggestions (#6418) --- CHANGELOG.md | 4 ++++ lib/install.ps1 | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55455b939c..b66a583370 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## [Unreleased](https://github.com/ScoopInstaller/Scoop/compare/v0.5.3...develop) +### Features + +- **install:** Add separator at the end of notes, highlight suggestions ([#6418](https://github.com/ScoopInstaller/Scoop/issues/6418)) + ### Bug Fixes - **scoop-download:** Fix function `nightly_version` not defined error ([#6386](https://github.com/ScoopInstaller/Scoop/issues/6386)) diff --git a/lib/install.ps1 b/lib/install.ps1 index 56cfdac924..0a82331a4a 100644 --- a/lib/install.ps1 +++ b/lib/install.ps1 @@ -359,6 +359,7 @@ function show_notes($manifest, $dir, $original_dir, $persist_dir) { Write-Output 'Notes' Write-Output '-----' Write-Output (wraptext (substitute $manifest.notes @{ '$dir' = $dir; '$original_dir' = $original_dir; '$persist_dir' = $persist_dir })) + Write-Output '-----' } } @@ -419,7 +420,7 @@ function show_suggestions($suggested) { } if (!$fulfilled) { - Write-Host "'$app' suggests installing '$([string]::join("' or '", $feature_suggestions))'." + Write-Host "'$app' suggests installing '$([string]::join("' or '", $feature_suggestions))'." -ForegroundColor DarkYellow } } } From db8d554f80607ad7554bb10ada31e01a6bd0036b Mon Sep 17 00:00:00 2001 From: Hsiao-nan Cheung Date: Fri, 26 Sep 2025 15:20:33 +0800 Subject: [PATCH 07/11] fix(scoop-update): Force sync tags w/ remote branch while scoop update (#6439) --- CHANGELOG.md | 1 + libexec/scoop-update.ps1 | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b66a583370..f5125f77d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ ### Bug Fixes +- **scoop-update**: Force sync tags w/ remote branch while scoop update ([#6439](https://github.com/ScoopInstaller/Scoop/issues/6439)) - **scoop-download:** Fix function `nightly_version` not defined error ([#6386](https://github.com/ScoopInstaller/Scoop/issues/6386)) - **autoupdate:** Use origin URL to handle URLs with fragment in GitHub mode ([#6455](https://github.com/ScoopInstaller/Scoop/issues/6455)) - **buckets|scoop-info:** Switch git log date format to ISO 8601 to avoid locale issues ([#6446](https://github.com/ScoopInstaller/Scoop/issues/6446)) diff --git a/libexec/scoop-update.ps1 b/libexec/scoop-update.ps1 index 9d41906eca..3a305c3dfc 100644 --- a/libexec/scoop-update.ps1 +++ b/libexec/scoop-update.ps1 @@ -136,7 +136,7 @@ function Sync-Scoop { # reset branch HEAD Invoke-Git -Path $currentdir -ArgumentList @('reset', '--hard', "origin/$configBranch", '-q') } else { - Invoke-Git -Path $currentdir -ArgumentList @('pull', '-q') + Invoke-Git -Path $currentdir -ArgumentList @('pull', '--tags', '--force', '-q') } $res = $lastexitcode From 4c55e7aebdd734eef7a068988d22e51a799c01fc Mon Sep 17 00:00:00 2001 From: abgox Date: Fri, 26 Sep 2025 17:14:09 +0800 Subject: [PATCH 08/11] feat(scoop-uninstall): Allow access to $bucket in uninstall scripts (#6380) --- CHANGELOG.md | 1 + libexec/scoop-uninstall.ps1 | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f5125f77d2..b62c008eae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### Features +- **scoop-uninstall**: Allow access to `$bucket` in uninstall scripts ([#6380](https://github.com/ScoopInstaller/Scoop/issues/6380)) - **install:** Add separator at the end of notes, highlight suggestions ([#6418](https://github.com/ScoopInstaller/Scoop/issues/6418)) ### Bug Fixes diff --git a/libexec/scoop-uninstall.ps1 b/libexec/scoop-uninstall.ps1 index 5bdd57e5d1..2d2a8e9ba9 100644 --- a/libexec/scoop-uninstall.ps1 +++ b/libexec/scoop-uninstall.ps1 @@ -58,6 +58,7 @@ if (!$apps) { exit 0 } $manifest = installed_manifest $app $version $global $install = install_info $app $version $global $architecture = $install.architecture + $bucket = $install.bucket Invoke-HookScript -HookType 'pre_uninstall' -Manifest $manifest -Arch $architecture From 2a637361ccce0c5e6970ee8a3e3bab0bde050ab6 Mon Sep 17 00:00:00 2001 From: HUMORCE Date: Fri, 26 Sep 2025 23:55:34 +0800 Subject: [PATCH 09/11] fix(scoop-uninstall): Correct `-Global` switch during uninstalling/updating (#6454) Co-authored-by: Hsiao-nan Cheung --- CHANGELOG.md | 3 ++- bin/uninstall.ps1 | 2 +- libexec/scoop-uninstall.ps1 | 2 +- libexec/scoop-update.ps1 | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b62c008eae..3d45cb1212 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,9 @@ ### Bug Fixes +- **scoop-download**: Fix function `nightly_version` not defined error ([#6386](https://github.com/ScoopInstaller/Scoop/issues/6386)) +- **scoop-uninstall:**: Correct `-Global` Switch ([#6454](https://github.com/ScoopInstaller/Scoop/issues/6454)) - **scoop-update**: Force sync tags w/ remote branch while scoop update ([#6439](https://github.com/ScoopInstaller/Scoop/issues/6439)) -- **scoop-download:** Fix function `nightly_version` not defined error ([#6386](https://github.com/ScoopInstaller/Scoop/issues/6386)) - **autoupdate:** Use origin URL to handle URLs with fragment in GitHub mode ([#6455](https://github.com/ScoopInstaller/Scoop/issues/6455)) - **buckets|scoop-info:** Switch git log date format to ISO 8601 to avoid locale issues ([#6446](https://github.com/ScoopInstaller/Scoop/issues/6446)) - **scoop-version:** Fix logic error caused by missing brackets ([#6463](https://github.com/ScoopInstaller/Scoop/issues/6463)) diff --git a/bin/uninstall.ps1 b/bin/uninstall.ps1 index 2e2dc36ea8..9302dd988a 100644 --- a/bin/uninstall.ps1 +++ b/bin/uninstall.ps1 @@ -42,7 +42,7 @@ function do_uninstall($app, $global) { $architecture = $install.architecture Write-Output "Uninstalling '$app'" - Invoke-Installer -Path $dir -Manifest $manifest -ProcessorArchitecture $architecture -Uninstall + Invoke-Installer -Path $dir -Manifest $manifest -ProcessorArchitecture $architecture -Global:$global -Uninstall rm_shims $app $manifest $global $architecture # If a junction was used during install, that will have been used diff --git a/libexec/scoop-uninstall.ps1 b/libexec/scoop-uninstall.ps1 index 2d2a8e9ba9..fdb6e8770e 100644 --- a/libexec/scoop-uninstall.ps1 +++ b/libexec/scoop-uninstall.ps1 @@ -75,7 +75,7 @@ if (!$apps) { exit 0 } continue } - Invoke-Installer -Path $dir -Manifest $manifest -ProcessorArchitecture $architecture -Global $global -Uninstall + Invoke-Installer -Path $dir -Manifest $manifest -ProcessorArchitecture $architecture -Global:$global -Uninstall rm_shims $app $manifest $global $architecture rm_startmenu_shortcuts $manifest $global $architecture diff --git a/libexec/scoop-update.ps1 b/libexec/scoop-update.ps1 index 3a305c3dfc..99e6a6dddb 100644 --- a/libexec/scoop-update.ps1 +++ b/libexec/scoop-update.ps1 @@ -341,7 +341,7 @@ function update($app, $global, $quiet = $false, $independent, $suggested, $use_c Invoke-HookScript -HookType 'pre_uninstall' -Manifest $old_manifest -Arch $architecture Write-Host "Uninstalling '$app' ($old_version)" - Invoke-Installer -Path $dir -Manifest $old_manifest -ProcessorArchitecture $architecture -Uninstall + Invoke-Installer -Path $dir -Manifest $old_manifest -ProcessorArchitecture $architecture -Global:$global -Uninstall rm_shims $app $old_manifest $global $architecture # If a junction was used during install, that will have been used From ca0506cf3e26d6b1038270dc32bc4f4804dc9a01 Mon Sep 17 00:00:00 2001 From: abgox Date: Mon, 29 Sep 2025 15:12:10 +0800 Subject: [PATCH 10/11] refactor(output): Replace raw prints with functions for standardized output (#6449) Co-authored-by: Hsiao-nan Cheung --- CHANGELOG.md | 4 ++++ lib/core.ps1 | 2 +- lib/install.ps1 | 2 +- libexec/scoop-alias.ps1 | 2 +- libexec/scoop-bucket.ps1 | 8 ++++---- libexec/scoop-cache.ps1 | 2 +- libexec/scoop-cleanup.ps1 | 6 +++--- libexec/scoop-help.ps1 | 6 +++--- libexec/scoop-hold.ps1 | 2 +- libexec/scoop-install.ps1 | 2 +- libexec/scoop-list.ps1 | 4 ++-- libexec/scoop-reset.ps1 | 2 +- libexec/scoop-shim.ps1 | 5 ++--- libexec/scoop-unhold.ps1 | 2 +- libexec/scoop-update.ps1 | 4 ++-- libexec/scoop-virustotal.ps1 | 2 +- 16 files changed, 29 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d45cb1212..9875359d01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,10 @@ - **scoop-version:** Fix logic error caused by missing brackets ([#6463](https://github.com/ScoopInstaller/Scoop/issues/6463)) - **core|manifest:** Avoid error messages when searching non-existent 'deprecated' directory ([#6471](https://github.com/ScoopInstaller/Scoop/issues/6471)) +### Code Refactoring + +- **output**: Replace raw prints with functions for standardized output ([#6449](https://github.com/ScoopInstaller/Scoop/issues/6449)) + ## [v0.5.3](https://github.com/ScoopInstaller/Scoop/compare/v0.5.2...v0.5.3) - 2025-08-11 ### Features diff --git a/lib/core.ps1 b/lib/core.ps1 index 2b9f8b68af..b0e833c74b 100644 --- a/lib/core.ps1 +++ b/lib/core.ps1 @@ -90,7 +90,7 @@ function load_cfg($file) { $content = [System.IO.File]::ReadAllLines($file) return ($content | ConvertFrom-Json -ErrorAction Stop) } catch { - Write-Host "ERROR loading $file`: $($_.exception.message)" + error "loading $file`: $($_.exception.message)" } } diff --git a/lib/install.ps1 b/lib/install.ps1 index 0a82331a4a..6125697967 100644 --- a/lib/install.ps1 +++ b/lib/install.ps1 @@ -285,7 +285,7 @@ function ensure_install_dir_not_in_path($dir, $global) { $fixed, $removed = find_dir_or_subdir $path "$dir" if ($removed) { - $removed | ForEach-Object { "Installer added '$(friendly_path $_)' to path. Removing." } + $removed | ForEach-Object { Write-Output "Installer added '$(friendly_path $_)' to path. Removing." } Set-EnvVar -Name 'PATH' -Value $fixed -Global:$global } diff --git a/libexec/scoop-alias.ps1 b/libexec/scoop-alias.ps1 index 677b9337f7..2b0545abe4 100644 --- a/libexec/scoop-alias.ps1 +++ b/libexec/scoop-alias.ps1 @@ -40,7 +40,7 @@ if ($SubCommand -notin $SubCommands) { } $opt, $other, $err = getopt $Args 'v' 'verbose' -if ($err) { "scoop alias: $err"; exit 1 } +if ($err) { error "scoop alias: $err"; exit 1 } $name, $command, $description = $other $verbose = $opt.v -or $opt.verbose diff --git a/libexec/scoop-bucket.ps1 b/libexec/scoop-bucket.ps1 index d3b7728559..39d8ccf8da 100644 --- a/libexec/scoop-bucket.ps1 +++ b/libexec/scoop-bucket.ps1 @@ -34,14 +34,14 @@ $usage_rm = 'usage: scoop bucket rm ' switch ($cmd) { 'add' { if (!$name) { - ' missing' + error ' missing' $usage_add exit 1 } if (!$repo) { $repo = known_bucket_repo $name if (!$repo) { - "Unknown bucket '$name'. Try specifying ." + error "Unknown bucket '$name'. Try specifying ." $usage_add exit 1 } @@ -51,7 +51,7 @@ switch ($cmd) { } 'rm' { if (!$name) { - ' missing' + error ' missing' $usage_rm exit 1 } @@ -73,7 +73,7 @@ switch ($cmd) { exit 0 } default { - "scoop bucket: cmd '$cmd' not supported" + error "scoop bucket: cmd '$cmd' not supported" my_usage exit 1 } diff --git a/libexec/scoop-cache.ps1 b/libexec/scoop-cache.ps1 index 30e8354fca..e81a626db7 100644 --- a/libexec/scoop-cache.ps1 +++ b/libexec/scoop-cache.ps1 @@ -35,7 +35,7 @@ function cacheshow($app) { function cacheremove($app) { if (!$app) { - 'ERROR: missing' + error ' missing' my_usage exit 1 } elseif ($app -eq '*' -or $app -eq '-a' -or $app -eq '--all') { diff --git a/libexec/scoop-cleanup.ps1 b/libexec/scoop-cleanup.ps1 index 6ce40a211f..3ea5194d0f 100644 --- a/libexec/scoop-cleanup.ps1 +++ b/libexec/scoop-cleanup.ps1 @@ -16,15 +16,15 @@ . "$PSScriptRoot\..\lib\install.ps1" # persist related $opt, $apps, $err = getopt $args 'agk' 'all', 'global', 'cache' -if ($err) { "scoop cleanup: $err"; exit 1 } +if ($err) { error "scoop cleanup: $err"; exit 1 } $global = $opt.g -or $opt.global $cache = $opt.k -or $opt.cache $all = $opt.a -or $opt.all -if (!$apps -and !$all) { 'ERROR: missing'; my_usage; exit 1 } +if (!$apps -and !$all) { error ' missing'; my_usage; exit 1 } if ($global -and !(is_admin)) { - 'ERROR: you need admin rights to cleanup global apps'; exit 1 + error 'you need admin rights to cleanup global apps'; exit 1 } function cleanup($app, $global, $verbose, $cache) { diff --git a/libexec/scoop-help.ps1 b/libexec/scoop-help.ps1 index 54ed8a9319..18a67fa9b1 100644 --- a/libexec/scoop-help.ps1 +++ b/libexec/scoop-help.ps1 @@ -27,17 +27,17 @@ function print_summaries { $commands = commands -if(!($cmd)) { +if (!($cmd)) { Write-Host "Usage: scoop [] Available commands are listed below. Type 'scoop help ' to get more help for a specific command." print_summaries -} elseif($commands -contains $cmd) { +} elseif ($commands -contains $cmd) { print_help $cmd } else { - warn "scoop help: no such command '$cmd'" + error "scoop help: no such command '$cmd'" exit 1 } diff --git a/libexec/scoop-hold.ps1 b/libexec/scoop-hold.ps1 index 504f20a849..48f8304c9a 100644 --- a/libexec/scoop-hold.ps1 +++ b/libexec/scoop-hold.ps1 @@ -15,7 +15,7 @@ . "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion' $opt, $apps, $err = getopt $args 'g' 'global' -if ($err) { "scoop hold: $err"; exit 1 } +if ($err) { error "scoop hold: $err"; exit 1 } $global = $opt.g -or $opt.global diff --git a/libexec/scoop-install.ps1 b/libexec/scoop-install.ps1 index 0fadcff09d..6af199a8b8 100644 --- a/libexec/scoop-install.ps1 +++ b/libexec/scoop-install.ps1 @@ -44,7 +44,7 @@ if (get_config USE_SQLITE_CACHE) { } $opt, $apps, $err = getopt $args 'giksua:' 'global', 'independent', 'no-cache', 'skip-hash-check', 'no-update-scoop', 'arch=' -if ($err) { "scoop install: $err"; exit 1 } +if ($err) { error "scoop install: $err"; exit 1 } $global = $opt.g -or $opt.global $check_hash = !($opt.s -or $opt.'skip-hash-check') diff --git a/libexec/scoop-list.ps1 b/libexec/scoop-list.ps1 index f757146d47..aded1e5ee0 100644 --- a/libexec/scoop-list.ps1 +++ b/libexec/scoop-list.ps1 @@ -17,7 +17,7 @@ $global = installed_apps $true | ForEach-Object { @{ name = $_; global = $true } $apps = @($local) + @($global) if (-not $apps) { - Write-Host "There aren't any apps installed." + warn "There aren't any apps installed." exit 1 } @@ -48,7 +48,7 @@ $apps | Where-Object { !$query -or ($_.name -match $query) } | ForEach-Object { $item.Updated = $updated $info = @() - if ((app_status $app $global).deprecated) { $info += 'Deprecated package'} + if ((app_status $app $global).deprecated) { $info += 'Deprecated package' } if ($global) { $info += 'Global install' } if (failed $app $global) { $info += 'Install failed' } if ($install_info.hold) { $info += 'Held package' } diff --git a/libexec/scoop-reset.ps1 b/libexec/scoop-reset.ps1 index 512540e8e6..1dd000a373 100644 --- a/libexec/scoop-reset.ps1 +++ b/libexec/scoop-reset.ps1 @@ -14,7 +14,7 @@ . "$PSScriptRoot\..\lib\shortcuts.ps1" $opt, $apps, $err = getopt $args 'a' 'all' -if($err) { "scoop reset: $err"; exit 1 } +if($err) { error "scoop reset: $err"; exit 1 } $all = $opt.a -or $opt.all if(!$apps -and !$all) { error ' missing'; my_usage; exit 1 } diff --git a/libexec/scoop-shim.ps1 b/libexec/scoop-shim.ps1 index 877b65b2e9..26f394dd56 100644 --- a/libexec/scoop-shim.ps1 +++ b/libexec/scoop-shim.ps1 @@ -48,7 +48,7 @@ if ($SubCommand -notin @('add', 'rm', 'list', 'info', 'alter')) { } $opt, $other, $err = getopt $Args 'g' 'global' -if ($err) { "scoop shim: $err"; exit 1 } +if ($err) { error "scoop shim: $err"; exit 1 } $global = $opt.g -or $opt.global @@ -147,8 +147,7 @@ switch ($SubCommand) { $pattern = $_ [void][Regex]::New($pattern) } catch { - Write-Host "ERROR: Invalid pattern: " -ForegroundColor Red -NoNewline - Write-Host $pattern -ForegroundColor Magenta + error "Invalid pattern: $([char]0x1b)[35m$pattern$([char]0x1b)[0m" exit 1 } } diff --git a/libexec/scoop-unhold.ps1 b/libexec/scoop-unhold.ps1 index 4e2413a340..88a859c81c 100644 --- a/libexec/scoop-unhold.ps1 +++ b/libexec/scoop-unhold.ps1 @@ -15,7 +15,7 @@ . "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion' $opt, $apps, $err = getopt $args 'g' 'global' -if ($err) { "scoop unhold: $err"; exit 1 } +if ($err) { error "scoop unhold: $err"; exit 1 } $global = $opt.g -or $opt.global diff --git a/libexec/scoop-update.ps1 b/libexec/scoop-update.ps1 index 99e6a6dddb..bc590a13f6 100644 --- a/libexec/scoop-update.ps1 +++ b/libexec/scoop-update.ps1 @@ -30,7 +30,7 @@ if (get_config USE_SQLITE_CACHE) { } $opt, $apps, $err = getopt $args 'gfiksqa' 'global', 'force', 'independent', 'no-cache', 'skip-hash-check', 'quiet', 'all' -if ($err) { "scoop update: $err"; exit 1 } +if ($err) { error "scoop update: $err"; exit 1 } $global = $opt.g -or $opt.global $force = $opt.f -or $opt.force $check_hash = !($opt.s -or $opt.'skip-hash-check') @@ -400,7 +400,7 @@ if (-not ($apps -or $all)) { success 'Scoop was updated successfully!' } else { if ($global -and !(is_admin)) { - 'ERROR: You need admin rights to update global apps.'; exit 1 + error 'You need admin rights to update global apps.'; exit 1 } $outdated = @() diff --git a/libexec/scoop-virustotal.ps1 b/libexec/scoop-virustotal.ps1 index 8fe63359cf..d56eb6e8b4 100644 --- a/libexec/scoop-virustotal.ps1 +++ b/libexec/scoop-virustotal.ps1 @@ -36,7 +36,7 @@ . "$PSScriptRoot\..\lib\depends.ps1" # 'Get-Dependency' $opt, $apps, $err = getopt $args 'asnup' @('all', 'scan', 'no-depends', 'no-update-scoop', 'passthru') -if ($err) { "scoop virustotal: $err"; exit 1 } +if ($err) { error "scoop virustotal: $err"; exit 1 } $all = $apps -eq '*' -or $opt.a -or $opt.all if (!$apps -and !$all) { my_usage; exit 1 } $architecture = Get-DefaultArchitecture From 7d7af80385f9f7eecac2f80bd9258c285d849158 Mon Sep 17 00:00:00 2001 From: Mert Emirimam <48881002+mertemr@users.noreply.github.com> Date: Fri, 3 Oct 2025 10:25:30 +0300 Subject: [PATCH 11/11] fix(Get-PESubsystem): Ensure resources are closed only if initialized. Fixes #6506 --- lib/core.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/core.ps1 b/lib/core.ps1 index b0e833c74b..bf281ec3c6 100644 --- a/lib/core.ps1 +++ b/lib/core.ps1 @@ -16,8 +16,8 @@ function Get-PESubsystem($filePath) { } catch { return -1 } finally { - $binaryReader.Close() - $fileStream.Close() + if ($null -ne $binaryReader) { $binaryReader.Close() } + if ($null -ne $fileStream) { $fileStream.Close() } } }