diff --git a/bin/scoop.ps1 b/bin/scoop.ps1 index fe5c1d85ce..58351fa5fb 100644 --- a/bin/scoop.ps1 +++ b/bin/scoop.ps1 @@ -15,8 +15,6 @@ Upgrade PowerShell: 'https://docs.microsoft.com/en-us/powershell/scripting/insta . (Join-Path $PSScriptRoot "..\lib\$_.ps1") } -Reset-Alias - $ExitCode = 0 # Powershell automatically bind bash like short parameters as $args, and does not put it in $Command parameter diff --git a/lib/Helpers.ps1 b/lib/Helpers.ps1 index 13b09f8601..e9c7a91780 100644 --- a/lib/Helpers.ps1 +++ b/lib/Helpers.ps1 @@ -246,61 +246,6 @@ function Get-MagicByte { } } -function _resetAlias($name, $value) { - $existing = Get-Alias $name -ErrorAction 'Ignore' - - if ($existing -and ($existing | Where-Object -Property 'Options' -Match 'readonly')) { - if ($existing.Definition -ne $value) { - Write-UserMessage "Alias $name is read-only; cannot reset it." -Warning - } - - # Already set - return - } - - if ($value -is [ScriptBlock]) { - if (!(Test-Path "Function:script:$name")) { - New-Item -Path Function: -Name "script:$name" -Value $value | Out-Null - } - - return - } - - Set-Alias $name $value -Scope 'Script' -Option 'AllScope' -} - -function Reset-Alias { - # For aliases where there's a local function, re-alias so the function takes precedence - $aliases = Get-Alias | Where-Object -Property 'Options' -NotMatch 'readonly|allscope' | Select-Object -ExpandProperty 'Name' - Get-ChildItem Function: | ForEach-Object { - $fn = $_.Name - if ($fn -in $aliases) { - Set-Alias $fn Local:$fn -Scope 'Script' - } - } - - # User aliases - $defautlAliases = @{ - 'cp' = 'Copy-Item' - 'echo' = 'Write-Output' - 'gc' = 'Get-Content' - 'gci' = 'Get-ChildItem' - 'gcm' = 'Get-Command' - 'gm' = 'Get-Member' - 'iex' = 'Invoke-Expression' - 'ls' = 'Get-ChildItem' - 'mkdir' = { New-Item -Type 'Directory' @args } - 'mv' = 'Move-Item' - 'rm' = 'Remove-Item' - 'sc' = 'Set-Content' - 'select' = 'Select-Object' - 'sls' = 'Select-String' - } - - # Set default aliases - $defautlAliases.Keys | ForEach-Object { _resetAlias $_ $defautlAliases[$_] } -} - function New-IssuePrompt { <# .SYNOPSIS diff --git a/lib/core.ps1 b/lib/core.ps1 index c018cc4233..2140799c2c 100644 --- a/lib/core.ps1 +++ b/lib/core.ps1 @@ -1121,11 +1121,6 @@ function Resolve-ArchitectureParameter { } #region Deprecated -function reset_aliases() { - Show-DeprecatedWarning $MyInvocation 'Reset-Alias' - Reset-Alias -} - function file_path($app, $file) { Show-DeprecatedWarning $MyInvocation 'Get-AppFilePath' return Get-AppFilePath -App $app -File $file diff --git a/libexec/scoop-bucket.ps1 b/libexec/scoop-bucket.ps1 index d251ac8f9f..1d6474acef 100644 --- a/libexec/scoop-bucket.ps1 +++ b/libexec/scoop-bucket.ps1 @@ -30,8 +30,6 @@ . (Join-Path $PSScriptRoot "..\lib\$_.ps1") } -Reset-Alias - $ExitCode = 0 $Options, $Bucket, $_err = Resolve-GetOpt $args diff --git a/libexec/scoop-cache.ps1 b/libexec/scoop-cache.ps1 index 3130042407..5292cf6455 100644 --- a/libexec/scoop-cache.ps1 +++ b/libexec/scoop-cache.ps1 @@ -21,8 +21,6 @@ . (Join-Path $PSScriptRoot "..\lib\$_.ps1") } -Reset-Alias - $ExitCode = 0 $Problems = 0 $Options, $Cache, $_err = Resolve-GetOpt $args diff --git a/libexec/scoop-cleanup.ps1 b/libexec/scoop-cleanup.ps1 index f3db0977bb..16876db9e3 100644 --- a/libexec/scoop-cleanup.ps1 +++ b/libexec/scoop-cleanup.ps1 @@ -13,8 +13,6 @@ . (Join-Path $PSScriptRoot "..\lib\$_.ps1") } -Reset-Alias - $ExitCode = 0 $Problems = 0 $Options, $Applications, $_err = Resolve-GetOpt $args 'gk' 'global', 'cache' diff --git a/libexec/scoop-config.ps1 b/libexec/scoop-config.ps1 index 0f2468bee6..3c8ec24cab 100644 --- a/libexec/scoop-config.ps1 +++ b/libexec/scoop-config.ps1 @@ -107,8 +107,6 @@ # TODO: Add --global - Ash258/Scoop-Core#5 -Reset-Alias - $ExitCode = 0 $null, $Config, $_err = Resolve-GetOpt $args diff --git a/libexec/scoop-depends.ps1 b/libexec/scoop-depends.ps1 index c32a7a007f..10614dcba0 100644 --- a/libexec/scoop-depends.ps1 +++ b/libexec/scoop-depends.ps1 @@ -9,8 +9,6 @@ . (Join-Path $PSScriptRoot "..\lib\$_.ps1") } -Reset-Alias - $ExitCode = 0 $Options, $Applications, $_err = Resolve-GetOpt $args 'a:' 'arch=' diff --git a/libexec/scoop-download.ps1 b/libexec/scoop-download.ps1 index 280d1a9b32..658c61a55e 100644 --- a/libexec/scoop-download.ps1 +++ b/libexec/scoop-download.ps1 @@ -13,8 +13,6 @@ . (Join-Path $PSScriptRoot "..\lib\$_.ps1") } -Reset-Alias - #region Parameter validation $opt, $application, $err = Resolve-GetOpt $args 'sba:u:' 'skip', 'all-architectures', 'arch=', 'utility=' if ($err) { Stop-ScoopExecution -Message "scoop download: $err" -ExitCode 2 } diff --git a/libexec/scoop-export.ps1 b/libexec/scoop-export.ps1 index 616c2d8e11..b274d7178a 100644 --- a/libexec/scoop-export.ps1 +++ b/libexec/scoop-export.ps1 @@ -46,8 +46,6 @@ TODO: Export: } #> -Reset-Alias - $ExitCode = 0 $Options, $null, $_err = Resolve-GetOpt $args diff --git a/libexec/scoop-help.ps1 b/libexec/scoop-help.ps1 index b5475d498d..a15bfcdeeb 100644 --- a/libexec/scoop-help.ps1 +++ b/libexec/scoop-help.ps1 @@ -8,8 +8,6 @@ . (Join-Path $PSScriptRoot "..\lib\$_.ps1") } -Reset-Alias - $ExitCode = 0 $Options, $Command, $_err = Resolve-GetOpt $args diff --git a/libexec/scoop-hold.ps1 b/libexec/scoop-hold.ps1 index 351c15eee3..2b87b82267 100644 --- a/libexec/scoop-hold.ps1 +++ b/libexec/scoop-hold.ps1 @@ -10,8 +10,6 @@ . (Join-Path $PSScriptRoot "..\lib\$_.ps1") } -Reset-Alias - $ExitCode = 0 $Problems = 0 $Options, $Applications, $_err = Resolve-GetOpt $args 'g' 'global' diff --git a/libexec/scoop-home.ps1 b/libexec/scoop-home.ps1 index bba77c9d8c..315d317235 100644 --- a/libexec/scoop-home.ps1 +++ b/libexec/scoop-home.ps1 @@ -8,8 +8,6 @@ . (Join-Path $PSScriptRoot "..\lib\$_.ps1") } -Reset-Alias - $ExitCode = 0 $Options, $Application, $_err = Resolve-GetOpt $args diff --git a/libexec/scoop-info.ps1 b/libexec/scoop-info.ps1 index ab8fcf8ac1..69a983747b 100644 --- a/libexec/scoop-info.ps1 +++ b/libexec/scoop-info.ps1 @@ -9,8 +9,6 @@ . (Join-Path $PSScriptRoot "..\lib\$_.ps1") } -Reset-Alias - $ExitCode = 0 $Options, $Application, $_err = Resolve-GetOpt $args 'a:' 'arch=' diff --git a/libexec/scoop-install.ps1 b/libexec/scoop-install.ps1 index 238043a1ca..8d5368f834 100644 --- a/libexec/scoop-install.ps1 +++ b/libexec/scoop-install.ps1 @@ -23,8 +23,6 @@ . (Join-Path $PSScriptRoot "..\lib\$_.ps1") } -Reset-Alias - # TODO: Export # TODO: Cleanup function is_installed($app, $global, $version) { diff --git a/libexec/scoop-list.ps1 b/libexec/scoop-list.ps1 index 19652f5e3d..de5a4fa673 100644 --- a/libexec/scoop-list.ps1 +++ b/libexec/scoop-list.ps1 @@ -13,8 +13,6 @@ . (Join-Path $PSScriptRoot "..\lib\$_.ps1") } -Reset-Alias - $ExitCode = 0 $Options, $Query, $_err = Resolve-GetOpt $args 'iur' 'installed', 'updated', 'reverse' diff --git a/libexec/scoop-prefix.ps1 b/libexec/scoop-prefix.ps1 index d443d8a0cf..ca865efedd 100644 --- a/libexec/scoop-prefix.ps1 +++ b/libexec/scoop-prefix.ps1 @@ -8,8 +8,6 @@ . (Join-Path $PSScriptRoot "..\lib\$_.ps1") } -Reset-Alias - $ExitCode = 0 $Options, $Application, $_err = Resolve-GetOpt $args diff --git a/libexec/scoop-reset.ps1 b/libexec/scoop-reset.ps1 index e0fd842606..8cc021c304 100644 --- a/libexec/scoop-reset.ps1 +++ b/libexec/scoop-reset.ps1 @@ -21,8 +21,6 @@ # TODO: Add --global -Reset-Alias - $ExitCode = 0 $Problems = 0 $Options, $Applications, $_err = Resolve-GetOpt $args diff --git a/libexec/scoop-search.ps1 b/libexec/scoop-search.ps1 index d189b7e8f9..6963d81534 100644 --- a/libexec/scoop-search.ps1 +++ b/libexec/scoop-search.ps1 @@ -13,8 +13,6 @@ . (Join-Path $PSScriptRoot "..\lib\$_.ps1") } -Reset-Alias - $ExitCode = 0 $LocalResults = @() $Options, $Query, $_err = Resolve-GetOpt $args 'r' 'remote' diff --git a/libexec/scoop-status.ps1 b/libexec/scoop-status.ps1 index 15880683a2..00340ffbb3 100644 --- a/libexec/scoop-status.ps1 +++ b/libexec/scoop-status.ps1 @@ -14,8 +14,6 @@ . (Join-Path $PSScriptRoot "..\lib\$_.ps1") } -Reset-Alias - $ExitCode = 0 $Failed = @() $Outdated = @() diff --git a/libexec/scoop-unhold.ps1 b/libexec/scoop-unhold.ps1 index 54590e29a4..d6a0deaee4 100644 --- a/libexec/scoop-unhold.ps1 +++ b/libexec/scoop-unhold.ps1 @@ -9,8 +9,6 @@ . (Join-Path $PSScriptRoot "..\lib\$_.ps1") } -Reset-Alias - $ExitCode = 0 $Problems = 0 $Options, $Applications, $_err = Resolve-GetOpt $args 'g' 'global' diff --git a/libexec/scoop-uninstall.ps1 b/libexec/scoop-uninstall.ps1 index 4dd3d65037..aa685253ba 100644 --- a/libexec/scoop-uninstall.ps1 +++ b/libexec/scoop-uninstall.ps1 @@ -11,8 +11,6 @@ . (Join-Path $PSScriptRoot "..\lib\$_.ps1") } -Reset-Alias - $ExitCode = 0 $Problems = 0 $Options, $Applications, $_err = Resolve-GetOpt $args 'gp' 'global', 'purge' diff --git a/libexec/scoop-update.ps1 b/libexec/scoop-update.ps1 index 01f2a7ab1a..2f3d145d6e 100644 --- a/libexec/scoop-update.ps1 +++ b/libexec/scoop-update.ps1 @@ -18,8 +18,6 @@ . (Join-Path $PSScriptRoot "..\lib\$_.ps1") } -Reset-Alias - $ExitCode = 0 $Problems = 0 $Options, $Applications, $_err = Resolve-GetOpt $args 'gfiksq' 'global', 'force', 'independent', 'no-cache', 'skip', 'quiet' diff --git a/libexec/scoop-utils.ps1 b/libexec/scoop-utils.ps1 index b07f1dbace..b957383d64 100644 --- a/libexec/scoop-utils.ps1 +++ b/libexec/scoop-utils.ps1 @@ -23,8 +23,6 @@ . (Join-Path $PSScriptRoot "..\lib\$_.ps1") } -Reset-Alias - $getopt = $args $AdditionalArgs = @() diff --git a/libexec/scoop-virustotal.ps1 b/libexec/scoop-virustotal.ps1 index 85ae660f2f..077a5d16f9 100644 --- a/libexec/scoop-virustotal.ps1 +++ b/libexec/scoop-virustotal.ps1 @@ -35,8 +35,6 @@ # TODO: --no-depends => --independent # TODO: Drop --scan?? -Reset-Alias - $ExitCode = 0 $Options, $Applications, $_err = Resolve-GetOpt $args 'a:sn' 'arch=', 'scan', 'no-depends' diff --git a/libexec/scoop-which.ps1 b/libexec/scoop-which.ps1 index 02ff6d3b05..684d3925e3 100644 --- a/libexec/scoop-which.ps1 +++ b/libexec/scoop-which.ps1 @@ -8,8 +8,6 @@ . (Join-Path $PSScriptRoot "..\lib\$_.ps1") } -Reset-Alias - $ExitCode = 0 $Options, $Command, $_err = Resolve-GetOpt $args diff --git a/test/Scoop-Core.Tests.ps1 b/test/Scoop-Core.Tests.ps1 index ab28377665..835cf05774 100644 --- a/test/Scoop-Core.Tests.ps1 +++ b/test/Scoop-Core.Tests.ps1 @@ -256,10 +256,6 @@ Describe 'ensure_robocopy_in_path' -Tag 'Scoop' { $shimdir = shimdir $false Mock versiondir { $repo_dir } - BeforeAll { - Reset-Alias - } - Context 'robocopy is not in path' { It 'shims robocopy when not on path' { Mock Test-CommandAvailable { $false }