-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or more
Description
Set-StrictMode should cause errors to terminate execution.
In most languages with exceptions, an unhandled exception causes the program to terminate. However, Powershell defaults to continuing on when an unhandled exception occurs.
As a result, I think it is currently widely considered a best practice to begin all scripts with:
$ErrorActionPreference = "Stop"
Set-StrictMode -Version 3.0
Proposed change
This should be equivalent to the above:
Set-StrictMode -Version 4.0
There is also some discussion in PowerShell/PowerShell-RFC#88 .
I think that whatever the mechanism for causing non-zero exit codes to halt execution, that should also be included in StrictMode.
Metadata
Metadata
Assignees
Labels
Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or more