-
Notifications
You must be signed in to change notification settings - Fork 293
Description
There's been some discussion recently about when it's appropriate to write errors ...
On behalf of the PowerShell Committee, @SteveL-MSFT wrote this:
@PowerShell/powershell-committee discussed this and we also discussed it in this morning's Community Call. We agreed that the intent is that if a literal is passed and is not found, it should return a non-terminating error. Cmdlets that don't have this behavior have bugs.
In cases where it's explicit or implicit filtering, it should return nothing.
The real issue is that we are missing Test-* cmdlets so users had to rely on current behavior with Get-* cmdlets to see if something exists and we should add those cmdlets in the future.
And then later clarified:
- the intent is for a literal to return a non-terminating error, but wildcards/filtering to return nothing
- we do not plan to accept changes to existing behavior to make them consistent, but any new cmdlets should adhere to this
- even without changing the existing cmdlets, we still want to introduce Test-* cmdlets and make that the norm and best practice
- if not documented, we need to document existing cmdlet behavior where it deviates from the intent
So I ask this community: is that right?
Should a Get command that takes a literal name always write an error when it does not return anything?
Pretend that PowerShell was green-field, and that whatever you decide here will not break existing code.
Would you want errors from commands like:
- Get-Module ModuleThatIsNotLoaded
- Get-Module ModuleThatIsNotInstalled -ListAvailable
- Get-ChildItem FolderThatDoesNotExist
- Get-ChildItem EmptyFolder
- Get-TypeData System.Boolean # there's no TypeData for this by default
What about listing commands where we expect to always have data, but there are edge cases:
- Get-Command -Verb Build # there aren't any commands that use this verb yet
- Get-History # As the first command in a session
- Get-Clipboard # If the clipboard is empty