You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The "d" alias on the "Directory" parameter for Get-ChildItem can never work #14700
Issue-BugIssue has been identified as a bug in the productUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdletsgeneral cmdlet issues
If you look at the parameters of Get-ChildItem, there's an alias:
> (Get-CommandGet-ChildItem).Parameters["Directory"].Aliases
ad
d
The problem is that the d alias CANNOT ever work, because the Directory parameter is dynamic, and Get-ChildItem already has a parameter that starts with "d" (the "Depth" parameter), so the -d switch always gets bound to the -Depth parameter (and the user gets prompted for an actual value).
Can we remove that alias, since it's just confusing users?
Good point, previously reported in #4739 (I've just closed the latter, because this issue is more focused).
Given that binding to the static parameters seemingly always takes precedence, the lessons to be drawn for future cmdlets are:
Do not define aliases for dynamic parameters that are prefix matches of the static parameter names / aliases, because the latter will preempt the former.
Ideally - I don't know if it's feasible, given that it could only be detected at runtime - cmdlets would detect this condition and report an error.
Static parameters taking precedence makes sense conceptually, especially in the context of provider cmdlets, so that, say, -d is always-Depth, irrespective of what provider is targeted, and not situationally either -Depth or -Directory.
Issue-BugIssue has been identified as a bug in the productUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdletsgeneral cmdlet issues
Activity
mklement0 commentedon Feb 3, 2021
Good point, previously reported in #4739 (I've just closed the latter, because this issue is more focused).
Given that binding to the static parameters seemingly always takes precedence, the lessons to be drawn for future cmdlets are:
Do not define aliases for dynamic parameters that are prefix matches of the static parameter names / aliases, because the latter will preempt the former.
Static parameters taking precedence makes sense conceptually, especially in the context of provider cmdlets, so that, say,
-dis always-Depth, irrespective of what provider is targeted, and not situationally either-Depthor-Directory.daxian-dbw commentedon May 6, 2021
Closed via #15171