Skip to content

New-Alias / Set-Alias shouldn't allow the alias target to be the same as the alias name. #20153

@mklement0

Description

@mklement0

Prerequisites

Steps to reproduce

Defining an alias whose target names is the same as the alias' itself makes no sense, yet:

  • such a definition is currently quietly accepted.
  • then fails on invocation.
# Note: 'oss' is a built-in *function*

Set-Alias oss oss

oss -?

Expected behavior

The Set-Alias call should fail.

Actual behavior

The Set-Alias definition is quietly accepted.

On trying to invoke the alias, a "is not recognized as a name of a cmdlet, function, script file, or executable program." error occurs.

Error details

No response

Environment data

PowerShell 7.4.0-preview.4

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    In-PRIndicates that a PR is out for the issueIssue-Enhancementthe issue is more of a feature request than a bugNeeds-TriageThe issue is new and needs to be triaged by a work group.WG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility module

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions