Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beta.9 - Module PSReadLine impacting ifelse block structure #575

Closed
MaximoTrinidad opened this issue Nov 7, 2017 · 1 comment
Closed

Comments

@MaximoTrinidad
Copy link

Current PowerShell behavior is to automatically load the PSReadLine module. But, this module is breaking the if-else block of code when using Copy/Paste into the PowerShell Console.

Steps to reproduce

  1. Open PowerShell "pwsh" Console.
  2. Copy/Paste the following code into the Console:
## - Code Snippet will verify if NuGet is already installed:
if (-not (Get-PackageSource | Where-Object{$_.Name -eq 'Nuget'})) 
{
    Register-PackageSource -Name Nuget -ProviderName NuGet -Location https://www.nuget.org/api/v2
}
else
{
    Write-Host "NuGet Already Exist! No Need to install."
}

Expected behavior

Process the code without errors.

Below, the results of executing the "if-else" block without errors, after executing "Remove-Module PSReadLine"

PS C:\Program Files\PowerShell\6.0.0-beta.9> if (-not (Get-PackageSource | Where-Object{$_.Name -eq 'Nuget'}))
>> {
>>     Register-PackageSource -Name Nuget -ProviderName NuGet -Location https://www.nuget.org/api/v2
>> }
>> else
>> {
>>     Write-Host "NuGet Already Exist! No Need to install."
>> }
>>
NuGet Already Exist! No Need to install.
PS C:\Program Files\PowerShell\6.0.0-beta.9>

Actual behavior

Paste code stopped executing after it reads the "else".

PS C:\Program Files\PowerShell\6.0.0-beta.9> if (-not (Get-PackageSource | Where-Object{$_.Name -eq 'Nuget'}))
>> {
>>     Register-PackageSource -Name Nuget -ProviderName NuGet -Location https://www.nuget.org/api/v2
>> }
PS C:\Program Files\PowerShell\6.0.0-beta.9> else
else : The term 'else' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ else
+ ~~~~
    + CategoryInfo          : ObjectNotFound: (else:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\Program Files\PowerShell\6.0.0-beta.9> {
>>     Write-Host "NuGet Already Exist! No Need to install."
>> }

    Write-Host "NuGet Already Exist! No Need to install."

PS C:\Program Files\PowerShell\6.0.0-beta.9>
PS C:\Program Files\PowerShell\6.0.0-beta.9>

Environment data

OS:
Windows 10 Insider Build 1702
Ubuntu 16.04.3

PowerShell Core Beta.9

## - Windows PowerShell Core
PS C:\Program Files\PowerShell\6.0.0-beta.9> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.0.0-beta.9
PSEdition                      Core
GitCommitId                    v6.0.0-beta.9
OS                             Microsoft Windows 10.0.17025
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

## - Linux PowerShell Core
PS /home/maxt> $PSVersionTable                                                                                           

Name                           Value                                                                                    
----                           -----                                                                                    
PSVersion                      6.0.0-beta.9                                                                             
PSEdition                      Core                                                                                     
GitCommitId                    v6.0.0-beta.9                                                                            
OS                             Linux 4.10.0-38-generic #42~16.04.1-Ubuntu SMP Tue Oct 10 16:32:20 UTC 2017              
Platform                       Unix                                                                                     
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                  
PSRemotingProtocolVersion      2.3                                                                                      
SerializationVersion           1.1.0.1                                                                                  
WSManStackVersion              3.0

if-else_01_2017-11-06_18-25-39

@lzybkr
Copy link
Member

lzybkr commented Nov 11, 2017

Closing in favor of #579 which covers all of the known issues with right-click paste.

@lzybkr lzybkr closed this as completed Nov 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants