diff --git a/src/Microsoft.PowerShell.Linux.Host/main.cs b/src/Microsoft.PowerShell.Linux.Host/main.cs
index a214846c69..63f8cdd7c7 100644
--- a/src/Microsoft.PowerShell.Linux.Host/main.cs
+++ b/src/Microsoft.PowerShell.Linux.Host/main.cs
@@ -177,6 +177,11 @@ OPTIONS
///
private string partialLine = string.Empty;
+ ///
+ /// To keep track of here-strings
+ ///
+ private bool hereString = false;
+
///
/// Gets or sets a value indicating whether the host application
/// should exit.
@@ -391,15 +396,24 @@ OPTIONS
catch (IncompleteParseException e)
{
incompleteLine = true;
+ cmd = cmd.Trim();
partialLine += cmd;
-
- while (partialLine[partialLine.Length - 1] == '`')
- {
- Console.WriteLine("Trimming...");
- partialLine = partialLine.Remove(partialLine.Length - 1);
- }
- partialLine += " ";
+ if (hereString || cmd.EndsWith("@\"") || cmd.EndsWith("@\'"))
+ {
+ hereString = true;
+
+ partialLine += System.Environment.NewLine;
+ }
+ else
+ {
+ while (partialLine[partialLine.Length - 1] == '`')
+ {
+ partialLine = partialLine.Remove(partialLine.Length - 1);
+ }
+
+ partialLine += " ";
+ }
}
finally
@@ -416,6 +430,7 @@ OPTIONS
if (!incompleteLine)
{
partialLine = string.Empty;
+ hereString = false;
}
}
}