$PSVersionTable: Copy / paste the following commands into the PowerShell Integrated Console, and paste the output here:
code -v
$pseditor.EditorServicesVersion
code --list-extensions --show-versions
$PSVersionTable
Name Value
---- -----
PSVersion 5.1.14393.0
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.0
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
I am experiencing a problem with null import value.
I have use a variable to accept a read-host which I just enter without typing any value.
With in vscode,
I have to use $a -eq $null to detect.
with in ISE
I have to use "" instead of $ull
$a = Read-Host "type in value"
if ($a -eq $null){
write-host "This is null"
}
if ($a -eq ""){
write-host "This is double quote"
}
Follow the instructions in the README
about capturing and sending logs.
Hi @SilverknightMel! Thanks for this. Yes, I think we should fix this in the PSIC so it is consistent with everything else (ISE and normal console).
Given that this has been in VSCode for (I imagine) quite some time now, this is technically a breaking change. However, "" seems like a more appropriate return value if no value is entered.
I'm not seeing the issue here? Read-Host should never return $null, either on the Integrated Console or from the powershell console. I tested this in both environments (1.7 extension, v5.1), and was unable to get Read-Host to return $null.
$a = Read-Host
> <ENTER>
$null -eq $a
> $false
'' -eq $a
> $true
Hmmmmmmm, yes, now that I've tested this, I can confirm the same behaviour that @TheIncorrigible1 is reporting.
Will close this. We can reopen later if the behaviour is reproducible on another platform. Might need a test on Windows Server 2016?
I can reproduce this.
Name Value
---- -----
PSVersion 5.1.14393.3053
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.3053
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
PowerShell Integrated Console in VSCode:
$a = Read-Host
> <ENTER>
$null -eq $a
False
'' -eq $a
True
$b = Read-Host -Prompt "Input"
Input: <ENTER>
$null -eq $b
True
'' -eq $b
False
PS-Console:
$a = Read-Host
> <ENTER>
$null -eq $a
False
'' -eq $a
True
$b = Read-Host -Prompt "Input"
Input: <ENTER>
$null -eq $b
False
'' -eq $b
True
The behaviour is different in VSCode when -Prompt is used while using Read-Host.
This is actually a dupe of https://github.com/PowerShell/vscode-powershell/issues/1790 and I have a PR out fixing it.
Most helpful comment
This is actually a dupe of https://github.com/PowerShell/vscode-powershell/issues/1790 and I have a PR out fixing it.