PowerShell / PowerShell/vscode-powershell

Built-in `help` function writes Unicode BOM () to host

Open
#1,104 16 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area-Extension Terminal Issue-Bug
Dominant language
TypeScript
Stars
1.9k
Forks
547
PR merge metrics
No merged PRs in 30d

Description

System Details
  • Operating system name and version: Windows 10 Version 1709
  • VS Code version: 1.18.0
  • PowerShell extension version: 1.5.1
  • Output from $PSVersionTable:
Name                           Value
----                           -----
PSVersion                      5.1.16299.64
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.16299.64
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
  • VSCode plugin list:
C:\> code --list-extensions --show-versions
bradygaster.azuretoolsforvscode@1.3.0
CoenraadS.bracket-pair-colorizer@0.10.13
DotJoshJohnson.xml@1.9.2
eamodio.gitlens@6.1.0
EditorConfig.EditorConfig@0.11.1
johnpapa.azure-functions-tools@0.3.1
KnisterPeter.vscode-github@0.23.0
ms-mssql.mssql@1.2.1
ms-vscode.azure-account@0.2.2
ms-vscode.csharp@1.13.1
ms-vscode.PowerShell@1.5.1
msazurermtools.azurerm-vscode-tools@0.3.7
patrys.vscode-code-outline@0.0.12
PeterJausovec.vscode-docker@0.0.22
rebornix.Ruby@0.15.0
somekittens.hot-dog-stand@6.6.9
vscodevim.vim@0.10.4
zgudino.editorconfig-vscode-snippet@0.2.0
Issue Description

When I use the help function, a few garbage unicode characters are written to the output stream. Using Get-Help instead of help works as expected. This only happens in the extension-provided Powershell Integrated Console, not the default vscode console.

C:\> help get-date

NAME
    Get-Date
[...snip...]
C:\> help get-date -showwindow

C:\> help get-date > $null
(no output)
C:\> get-help get-date -showwindow
(no output)

On my system, the definition of the help function is:

C:\> Get-Command help | select -ExpandProperty Definition
<#
.FORWARDHELPTARGETNAME Get-Help
.FORWARDHELPCATEGORY Cmdlet 
#>
[CmdletBinding(DefaultParameterSetName='AllUsersView', HelpUri='https://go.microsoft.com/fwlink/?LinkID=113316')]
param(
    [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)]
    [string]
    ${Name},

    [string]
    ${Path},

    [ValidateSet('Alias','Cmdlet','Provider','General','FAQ','Glossary','HelpFile','ScriptCommand','Function','Filter','ExternalScript','All','DefaultHelp','Workflow','DscResource','Class','Configuration')]
    [string[]]
    ${Category},

    [string[]]
    ${Component},

    [string[]]
    ${Functionality},

    [string[]]
    ${Role},

    [Parameter(ParameterSetName='DetailedView', Mandatory=$true)]
    [switch]
    ${Detailed},

    [Parameter(ParameterSetName='AllUsersView')]
    [switch]
    ${Full},

    [Parameter(ParameterSetName='Examples', Mandatory=$true)]
    [switch]
    ${Examples},

    [Parameter(ParameterSetName='Parameters', Mandatory=$true)]
    [string]
    ${Parameter},

    [Parameter(ParameterSetName='Online', Mandatory=$true)]
    [switch]
    ${Online},

    [Parameter(ParameterSetName='ShowWindow', Mandatory=$true)]
    [switch]
    ${ShowWindow})

    #Set the outputencoding to Console::OutputEncoding. More.com doesn't work well with Unicode.
    $outputEncoding=[System.Console]::OutputEncoding

    Get-Help @PSBoundParameters | more

... and more is defined as ...

C:\> Get-Command more | select -ExpandProperty Definition

param([string[]]$paths)
$OutputEncoding = [System.Console]::OutputEncoding
if($paths) {
    foreach ($file in $paths)
    {
        Get-Content $file | more.com
    }
} else { $input | more.com }
Attached Logs

1510862054-d0c22b7a-9fe8-4400-9e12-9cb2d4fd6b5a1510862041231.zip

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named. Reproduce the issue in the extension-provided PowerShell Integrated Console with help get-date, then compare Get-Help and the default VS Code console. Trace the help and more entry points and output encoding behavior; done means the BOM is absent while normal output, -showwindow, and redirection still behave as reported.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell, typescript, vscode
Domain
cli, developer-experience, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.