Skip to content

PSIC Read-Host returns $null when input is left empty #1790

Closed
PowerShell/PowerShellEditorServices
#1174
@PXCSW-TR

Description

@PXCSW-TR

To help diagnose your issue, the following details are helpful:

  • Operating system name and version: Windows 10 1803 x64
  • VS Code version: 1.32.2 x64
  • PowerShell extension version; 1.11.0
  • Output from $PSVersionTable

System Details Output

Name                           Value
----                           -----
PSVersion                      5.1.17763.316
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17763.316
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Description

Return Value of Read-Host is $null when -Prompt is used and input is left empty

$value = Read-Host "Something"
Something:
$null -eq $value
True
$value = Read-Host -Prompt "Something"
Something:
$null -eq $value
True
$value = Read-Host

$value -eq ""
True

Expected Behaviour

Return Value is an empty string / ""

Actual Behaviour

Return Value is $null

Attached Logs

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions