Skip to content

Bug in Formatting while being without console #11776

@inf9144

Description

@inf9144

Hello,
running pwsh 7.0.0-rc2 on my build server the following happens when my own cmdlet raises an exception:
`

05-Feb-2020 10:35:56  
05-Feb-2020 10:35:56 OperationStopped:
05-Feb-2020 10:35:56 Line |
05-Feb-2020 10:35:56 161 | …         if ([Console]::WindowWidth -gt 0 -and ($message.Length - $pre …
05-Feb-2020 10:35:56  
05-Feb-2020 10:35:56 |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
05-Feb-2020 10:35:56 | Das Handle ist ungültig.
`

You are trying to read WindowWidth but there is no window. So you get Invalid Handle for the non existing console window.

Happens here on line 1154: https://github.com/PowerShell/PowerShell/blob/master/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs

Please fix.

Thanks!

Metadata

Metadata

Assignees

Labels

Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aWG-Enginecore PowerShell engine, interpreter, and runtime

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions