PowerShell / PowerShell/PowerShell
ConciseView mangles multiline errors thrown from scripts, but not from binary cmdlets
还没有人认领这个 Issue。
- 主要语言
- C#
- 星标
- 55.5k
- 派生
- 8.5k
- 平均合并
- 1 天 2 小时
- 30 天内合并 PR
- 88
描述
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
echo 'throw "test`ntest"' >script.ps1
.\script.ps1
If a script throws a multi-line error using throw, all newlines are replaced with spaces. This does not happen with binary cmdlets and advanced functions using $PSCmdlet.ThrowTerminatingError(). Structured error messages are much harder to read this way. Example from one of my scripts:
throw ("Pog cannot create symbolic links, which are currently necessary for correct functionality.`n" +`
"To allow creating symbolic links, do any of the following and re-run '$PSCommandPath':`n" +`
" 1) Enable Developer Mode. (Settings -> Update & Security -> For developers -> Developer Mode)`n" +`
" 2) Allow your user account to create symbolic links using Group Policy.`n" +`
" (Windows Settings -> Security Settings -> Local Policies -> User Rights Assignment -> Create symbolic links)`n" +`
" 3) Always run Pog as administrator.")
Expected behavior
Exception: D:\_\pog\setup.ps1:39
Line |
39 | throw ("Pog cannot create symbolic links, which are currently nec …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Pog cannot create symbolic links, which are currently necessary for correct functionality.
| To allow creating symbolic links, do any of the following and re-run 'D:\_\pog\setup.ps1':
| 1) Enable Developer Mode. (Settings -> Update & Security -> For developers -> Developer Mode)
| 2) Allow your user account to create symbolic links using Group Policy.
| (Windows Settings -> Security Settings -> Local Policies -> User Rights Assignment -> Create symbolic links)
| 3) Always run Pog as administrator.
Actual behavior
Exception: D:\_\pog\setup.ps1:39
Line |
39 | throw ("Pog cannot create symbolic links, which are currently nec …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Pog cannot create symbolic links, which are currently necessary for correct functionality. To allow creating symbolic links, do any of the following and re-run 'D:\_\pog\setup.ps1': 1) Enable
| Developer Mode. (Settings -> Update & Security -> For developers -> Developer Mode) 2) Allow your user account to create symbolic links using Group Policy. (Windows Settings -> Security
| Settings -> Local Policies -> User Rights Assignment -> Create symbolic links) 3) Always run Pog as administrator.
Error details
No response
Environment data
Name Value
---- -----
PSVersion 7.5.0-preview.2
PSEdition Core
GitCommitId 7.5.0-preview.2
OS Microsoft Windows 10.0.19045
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
No response
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
Reproduce the issue with the provided script.ps1 example and compare ConciseView output for script throw statements against binary cmdlets and advanced functions using $PSCmdlet.ThrowTerminatingError(). Trace the ConciseView error-formatting path; done means multiline script errors retain their newlines while the existing formatting remains intact.
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- csharp, powershell
- 领域
- cli
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100