From 89ad38beae9693f29b9aa4c20bb7a55fb4977992 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 5 Feb 2016 11:51:17 -0800 Subject: [PATCH] Guard prompt function Fixes #485. --- src/Microsoft.PowerShell.Linux.Host/main.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.PowerShell.Linux.Host/main.cs b/src/Microsoft.PowerShell.Linux.Host/main.cs index 8ffbe86611..dc263e217d 100644 --- a/src/Microsoft.PowerShell.Linux.Host/main.cs +++ b/src/Microsoft.PowerShell.Linux.Host/main.cs @@ -500,7 +500,16 @@ OPTIONS // the user calling "exit". while (!this.ShouldExit && this.myHost.Runspace != null) { - string prompt = Prompt(this.myHost.Runspace); + // If the prompt function failed for any reason, use a sane default + string prompt; + try + { + prompt = Prompt(this.myHost.Runspace); + } + catch + { + prompt = "PS> "; + } this.myHost.UI.Write(ConsoleColor.White, ConsoleColor.Black, prompt); string cmd = consoleReadLine.Read(this.myHost.Runspace);