Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,6 @@ private void DisplayBanner(PSHostUserInterface hostUI, string? bannerText)
if (!string.IsNullOrEmpty(bannerText))
{
hostUI.WriteLine(bannerText);
hostUI.WriteLine();
}

if (UpdatesNotification.CanNotifyUpdates)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ internal static void ShowUpdateNotification(PSHostUserInterface hostUI)

string notificationMsg = string.Format(CultureInfo.CurrentCulture, notificationMsgTemplate, releaseTag, notificationColor, resetColor, line2Padding, line3Padding);

hostUI.WriteLine();
hostUI.WriteLine(notificationMsg);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,7 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="ShellBannerNonWindowsPowerShell" xml:space="preserve">
<value>PowerShell {0}
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.</value>
<value>PowerShell {0}</value>
</data>
<data name="PSReadLineDisabledWhenScreenReaderIsActive" xml:space="preserve">
<value>Warning: PowerShell detected that you might be using a screen reader and has disabled PSReadLine for compatibility purposes. If you want to re-enable it, run 'Import-Module PSReadLine'.</value>
Expand Down Expand Up @@ -383,7 +379,7 @@ All parameters are case-insensitive.</value>

-NoLogo | -nol

Hides the copyright banner at startup of interactive sessions.
Hides the banner text at startup of interactive sessions.

-NonInteractive | -noni

Expand Down
58 changes: 58 additions & 0 deletions test/powershell/Host/ConsoleHost.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,64 @@ namespace StackTest {
$LASTEXITCODE | Should -Be $ExitCodeBadCommandLineParameter
}
}

Context "Startup banner text tests" -Tag Slow {
BeforeAll {
$outputPath = "Temp:\StartupBannerTest-Output-${Pid}.txt"
$inputPath = "Temp:\StartupBannerTest-Input.txt"
"exit" > $inputPath

# Not testing update notification banner text here
$oldPowerShellUpdateCheck = $env:POWERSHELL_UPDATECHECK
$env:POWERSHELL_UPDATECHECK = "Off"

# Set TERM to "dumb" to avoid DECCKM codes in the output
$oldTERM = $env:TERM
$env:TERM = "dumb"
Comment on lines +847 to +849
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be done only on non-Windows?

Copy link
Collaborator Author

@rkeithhill rkeithhill Jan 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It probably only needs to be done non-WIndows since the DECCKM failures I saw were on mac/linux. That said, I don't believe it hurts to set TERM="dumb" on Windows.


$escPwd = [regex]::Escape($pwd)
$expectedPromptPattern = "^PS ${escPwd}> exit`$"

$spArgs = @{
FilePath = $powershell
ArgumentList = @("-NoProfile")
RedirectStandardInput = $inputPath
RedirectStandardOutput = $outputPath
WorkingDirectory = $pwd
PassThru = $true
NoNewWindow = $true
UseNewEnvironment = $false
}
}
AfterAll {
$env:TERM = $oldTERM
$env:POWERSHELL_UPDATECHECK = $oldPowerShellUpdateCheck

Remove-Item $inputPath -Force -ErrorAction Ignore
Remove-Item $outputPath -Force -ErrorAction Ignore
}
BeforeEach {
Remove-Item $outputPath -Force -ErrorAction Ignore
}
It "Displays expected startup banner text by default" {
$process = Start-Process @spArgs
Wait-UntilTrue -sb { $process.HasExited } -TimeoutInMilliseconds 5000 -IntervalInMilliseconds 250 | Should -BeTrue

$out = @(Get-Content $outputPath)
$out.Count | Should -Be 2
$out[0] | Should -BeExactly "PowerShell $($PSVersionTable.GitCommitId)"
$out[1] | Should -MatchExactly $expectedPromptPattern
}
It "Displays only the prompt with -NoLogo" {
$spArgs["ArgumentList"] += "-NoLogo"
$process = Start-Process @spArgs
Wait-UntilTrue -sb { $process.HasExited } -TimeoutInMilliseconds 5000 -IntervalInMilliseconds 250 | Should -BeTrue

$out = @(Get-Content $outputPath)
$out.Count | Should -Be 1
$out[0] | Should -MatchExactly $expectedPromptPattern
}
}
}

Describe "WindowStyle argument" -Tag Feature {
Expand Down