mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
[release/v7.6] Properly Expand Aliases to their actual ResolvedCommand (#26571)
Co-authored-by: Ryan Yates <ryan.yates@kilasuit.org>
This commit is contained in:
co-authored by
Ryan Yates
parent
2e047922ca
commit
6827de520b
@@ -565,9 +565,7 @@ namespace System.Management.Automation.Runspaces
|
||||
typeName,
|
||||
new PSScriptProperty(
|
||||
@"DisplayName",
|
||||
GetScriptBlock(@"if ($this.Name.IndexOf('-') -lt 0)
|
||||
{
|
||||
if ($null -ne $this.ResolvedCommand)
|
||||
GetScriptBlock(@"if ($null -ne $this.ResolvedCommand)
|
||||
{
|
||||
$this.Name + "" -> "" + $this.ResolvedCommand.Name
|
||||
}
|
||||
@@ -575,11 +573,7 @@ namespace System.Management.Automation.Runspaces
|
||||
{
|
||||
$this.Name + "" -> "" + $this.Definition
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this.Name
|
||||
}"),
|
||||
"),
|
||||
setterScript: null,
|
||||
shouldCloneOnAccess: true),
|
||||
typeMembers,
|
||||
|
||||
@@ -155,6 +155,16 @@ Describe "Get-Alias DRT Unit Tests" -Tags "CI" {
|
||||
$returnObject[$i].Definition | Should -Be 'Get-Command'
|
||||
}
|
||||
}
|
||||
|
||||
It "Get-Alias DisplayName should always show AliasName -> ResolvedCommand for all aliases" {
|
||||
Set-Alias -Name Test-MyAlias -Value Get-Command -Force
|
||||
Set-Alias -Name tma -Value Test-MyAlias -force
|
||||
$aliases = Get-Alias Test-MyAlias, tma
|
||||
$aliases | ForEach-Object {
|
||||
$_.DisplayName | Should -Be "$($_.Name) -> Get-Command"
|
||||
}
|
||||
$aliases.Name.foreach{Remove-Item Alias:$_ -ErrorAction SilentlyContinue}
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Get-Alias" -Tags "CI" {
|
||||
|
||||
Reference in New Issue
Block a user