max*_*dbe 31 console powershell
如果我有一个可执行文件out.exe,它stdout被重定向到一个文件,即:
out.exe > $file
现在,如果我这样做,它只输出:
<----------------------------->
80 columns per line to the file
Run Code Online (Sandbox Code Playgroud)
有没有办法让控制台列数中的标准输出更宽?这是在out.exe某种程度上混乱列?就我而言,我正在使用fxcopcmd.exe.
Emp*_*LII 42
我不久前遇到了类似的问题.这是我做的修复它:
# Update output buffer size to prevent clipping in Visual Studio output window.
if( $Host -and $Host.UI -and $Host.UI.RawUI ) {
$rawUI = $Host.UI.RawUI
$oldSize = $rawUI.BufferSize
$typeName = $oldSize.GetType( ).FullName
$newSize = New-Object $typeName (500, $oldSize.Height)
$rawUI.BufferSize = $newSize
}
Run Code Online (Sandbox Code Playgroud)
它只是在主机的RawUI输出缓冲区上设置了500个字符的新宽度(但是,因为我们在几个环境中运行我们的构建,并且我们不希望脚本失败只是因为它无法使输出变得更大,代码相当防守).
如果您在一个始终设置RawUI的环境中运行(并且大多数都这样做),则代码可以大大简化:
$Host.UI.RawUI.BufferSize = New-Object Management.Automation.Host.Size (500, 25)
Run Code Online (Sandbox Code Playgroud)
Lee*_*Lee 12
无论是out-file和out-string命令有一个width参数:
out.exe | out-file -width 132 -filePath $file
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
38362 次 |
| 最近记录: |