-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.The issue is fixed.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime
Description
<#
Steps:
1. Ensure terminal is 120 characters or less wide
2. Save this script to a file (e.g. bug.ps1), then run with ./bug.ps1
Expected: See compact error view outline of the exception message
Actual: Script terminates without showing any error
Looking at $error[0] shows Substring error in a powershell formatter
MethodInvocationException:
Line |
172 | … $remainingMessage = $remainingMessage.Substring($substrin …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Exception calling "Substring" with "1" argument(s): "StartIndex cannot be less than zero. (Parameter 'startIndex')"
This is in:
https://github.com/PowerShell/PowerShell/blob/66912b7428d1f042cafaff70a76c60007716f4a7/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs
#>
function Break-CompactErrorView {
$msg = @"
0
"@
$errorMsg = ''
for ($i = 0; $i -lt 121; $i++) {
$errorMsg += $msg
}
throw $errorMsg
}
$error.Clear()
Break-CompactErrorViewNote that if pasting the script directly into a console window and running it, the expected behaviour occurs - only if run from a saved script does the exception get "lost" due to the exception in the error formatting code.
foo.ps1
Name Value
---- -----
PSVersion 7.0.0-rc.2
PSEdition Core
GitCommitId 7.0.0-rc.2
OS Microsoft Windows 10.0.18363
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Also occurs on Linux (both rc1 and rc2, rc1 shown here):
Name Value
---- -----
PSVersion 7.0.0-rc.1
PSEdition Core
GitCommitId 7.0.0-rc.1
OS Linux 4.14.158-129.185.amzn2.x86_64 #1 SMP Tue …
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Daily build from powershell-core-daily - not sure if this is the most recent as I've never run dailies before:
Name Value
---- -----
PSVersion 7.0.0-dailypreview7.45555
PSEdition Core
GitCommitId 7.0.0-dailypreview7.45555
OS Microsoft Windows 10.0.18363
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Metadata
Metadata
Assignees
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.The issue is fixed.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime