diff --git a/Duplicati/CommandLine/Help.cs b/Duplicati/CommandLine/Help.cs index 0eb63a4a2..5bb3a8b6e 100644 --- a/Duplicati/CommandLine/Help.cs +++ b/Duplicati/CommandLine/Help.cs @@ -357,6 +357,7 @@ namespace Duplicati.CommandLine private static void PrintFormatted(IEnumerable lines) { + int windowWidth = Math.Max(12, Console.WindowWidth == 0 ? 80 : Console.WindowWidth); foreach (string s in lines) { if (string.IsNullOrEmpty(s) || s.Trim().Length == 0) @@ -378,7 +379,7 @@ namespace Duplicati.CommandLine while (c.Length > 0) { - int len = Math.Min(Console.WindowWidth - 2, leadingSpaces.Length + c.Length); + int len = Math.Min(windowWidth - 2, leadingSpaces.Length + c.Length); len -= leadingSpaces.Length; if (len < c.Length) { diff --git a/Duplicati/CommandLine/Program.cs b/Duplicati/CommandLine/Program.cs index ce726d2c0..f8dcb9b8d 100644 --- a/Duplicati/CommandLine/Program.cs +++ b/Duplicati/CommandLine/Program.cs @@ -747,6 +747,7 @@ namespace Duplicati.CommandLine lines.Add(""); } + int windowWidth = Math.Max(12, Console.WindowWidth == 0 ? 80 : Console.WindowWidth); foreach (string s in lines) { if (string.IsNullOrEmpty(s)) @@ -766,7 +767,7 @@ namespace Duplicati.CommandLine while (c.Length > 0) { - int len = Math.Min(Console.WindowWidth - 2, leadingSpaces.Length + c.Length); + int len = Math.Min(windowWidth - 2, leadingSpaces.Length + c.Length); len -= leadingSpaces.Length; if (len < c.Length) {