From fef46672abfb01fa611ead181a2d811634629980 Mon Sep 17 00:00:00 2001 From: Scott Selberg Date: Mon, 6 Apr 2020 18:36:03 -0600 Subject: [PATCH] Feature/eliminate newlines (#483) * Added code to collapse newlines, line returns and groups of spaces into a single space. This is to allow users to put lots of arguments into the configuration xml using one line per argument for readability. This is really helpful when trying to wrap swarm-client.jar calls which can have a lot of long arguments. * fixed the comment text. * included tabs in the list of things to collapse. * added back in the missing space for the tab. * Switched to a regex. * Just removing newlines, line returns and tabs. * Trimming off leading and trailing whitespace. * Updated per recommendation from NextTurn. --- src/Core/ServiceWrapper/Main.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Core/ServiceWrapper/Main.cs b/src/Core/ServiceWrapper/Main.cs index 246642a..93345b0 100644 --- a/src/Core/ServiceWrapper/Main.cs +++ b/src/Core/ServiceWrapper/Main.cs @@ -8,6 +8,7 @@ using System.Runtime.InteropServices; using System.Security.AccessControl; using System.ServiceProcess; using System.Text; +using System.Text.RegularExpressions; using System.Threading; #if VNEXT using System.Threading.Tasks; @@ -276,6 +277,11 @@ namespace winsw startarguments += " " + _descriptor.Arguments; } + // Converting newlines, line returns, tabs into a single + // space. This allows users to provide multi-line arguments + // in the xml for readability. + startarguments = Regex.Replace(startarguments, @"\s*[\n\r]+\s*", " "); + LogEvent("Starting " + _descriptor.Executable + ' ' + startarguments); Log.Info("Starting " + _descriptor.Executable + ' ' + startarguments);