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

Support notification on pwsh startup when a new release is available #10689

Merged
merged 9 commits into from
Oct 8, 2019
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 @@ -1018,6 +1018,11 @@ private void ParseHelper(string[] args)
if (_showBanner && !_showHelp)
{
DisplayBanner();

if (UpdatesNotification.CanNotifyUpdates)
{
UpdatesNotification.ShowUpdateNotification(_hostUI);
}
}

Dbg.Assert(
Expand Down
39 changes: 21 additions & 18 deletions src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ internal sealed partial class ConsoleHost
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SystemParametersInfo(uint uiAction, uint uiParam, ref bool pvParam, uint fWinIni);

// NTRAID#Windows Out Of Band Releases-915506-2005/09/09
// Removed HandleUnexpectedExceptions infrastructure
/// <summary>
/// Internal Entry point in msh console host implementation.
/// </summary>
Expand All @@ -78,8 +76,8 @@ internal sealed partial class ConsoleHost
/// <returns>
/// The exit code for the shell.
///
/// NTRAID#Windows OS Bugs-1036968-2005/01/20-sburns The behavior here is related to monitor work. The low word of the
/// exit code is available for the user. The high word is reserved for the shell and monitor.
/// The behavior here is related to monitor work.
/// The low word of the exit code is available for the user. The high word is reserved for the shell and monitor.
///
/// The shell process needs to return:
///
Expand All @@ -98,13 +96,10 @@ internal sealed partial class ConsoleHost
/// or 0xFFFE0000 (user hit ctrl-break), the monitor should restart the shell.exe. Otherwise, the monitor should exit
/// with the same exit code as the shell.exe.
///
/// Anyone checking the exit code of the shell or monitor can mask off the hiword to determine the exit code passed
/// Anyone checking the exit code of the shell or monitor can mask off the high word to determine the exit code passed
/// by the script that the shell last executed.
/// </returns>
internal static int Start(
string bannerText,
string helpText,
string[] args)
internal static int Start(string bannerText, string helpText, string[] args)
{
#if DEBUG
if (Environment.GetEnvironmentVariable("POWERSHELL_DEBUG_STARTUP") != null)
Expand Down Expand Up @@ -162,10 +157,8 @@ internal static int Start(
hostException = e;
}

s_cpp = new CommandLineParameterParser(
(s_theConsoleHost != null) ? s_theConsoleHost.UI : new NullHostUserInterface(),
bannerText, helpText);

PSHostUserInterface hostUi = s_theConsoleHost?.UI ?? new NullHostUserInterface();
s_cpp = new CommandLineParameterParser(hostUi, bannerText, helpText);
s_cpp.Parse(args);

#if UNIX
Expand Down Expand Up @@ -239,10 +232,20 @@ internal static int Start(
throw hostException;
}

ProfileOptimization.StartProfile(
s_theConsoleHost.LoadPSReadline()
? "StartupProfileData-Interactive"
: "StartupProfileData-NonInteractive");
if (s_theConsoleHost.LoadPSReadline())
{
ProfileOptimization.StartProfile("StartupProfileData-Interactive");

if (UpdatesNotification.CanNotifyUpdates)
{
// Start a task in the background to check for the update release.
_ = UpdatesNotification.CheckForUpdates();
}
}
else
{
ProfileOptimization.StartProfile("StartupProfileData-NonInteractive");
}

s_theConsoleHost.BindBreakHandler();
PSHost.IsStdOutputRedirected = Console.IsOutputRedirected;
Expand Down Expand Up @@ -1532,7 +1535,7 @@ private bool LoadPSReadline()
// Don't load PSReadline if:
// * we don't think the process will be interactive, e.g. -command or -file
// - exception: when -noexit is specified, we will be interactive after the command/file finishes
// * -noninteractive: this should be obvious, they've asked that we don't every prompt
// * -noninteractive: this should be obvious, they've asked that we don't ever prompt
//
// Note that PSReadline doesn't support redirected stdin/stdout, but we don't check that here because
// a future version might, and we should automatically load it at that unknown point in the future.
Expand Down
Loading