From 6620aaf1bd072b8e86adc0a1541109cb51506e28 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 16 Feb 2025 17:39:05 -0600 Subject: fall back to DefaultExecutable if none specified --- src/slskd/Integrations/Scripts/ScriptService.cs | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'src/slskd/Integrations/Scripts/ScriptService.cs') diff --git a/src/slskd/Integrations/Scripts/ScriptService.cs b/src/slskd/Integrations/Scripts/ScriptService.cs index b3092a56..0c3bf5b6 100644 --- a/src/slskd/Integrations/Scripts/ScriptService.cs +++ b/src/slskd/Integrations/Scripts/ScriptService.cs @@ -85,28 +85,12 @@ public class ScriptService try { var run = script.Value.Run; - string executable = default; - string args = default; + string executable = run.Executable ?? DefaultExecutable; + string args = run.Command; - // determine whether the executable is wrapped in quotes, and if so, set the executable to the - // text contained within. the regex contains two capturing groups; the initial quoted string, and - // everything that comes after. if both groups capture something, we were given a quoted string to start - // otherwise no quotes were used, and we should use the first word as the executable - var matches = LeadingQuotedString.Matches(run); - - if (matches.Count == 2) - { - executable = matches[0].Value; - args = matches[1].Value; - } - else + if (string.IsNullOrEmpty(executable)) { - // didn't start with a quoted string, so just split the string into at most 2 parts, leaving - // part [0] the executable and part [1] the rest of the string (but possibly null) - var parts = run.Split(" ", count: 2, options: StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.RemoveEmptyEntries); - - executable = parts[0]; - args = parts.Length > 1 ? parts[1] : null; + Log.Warning("Script '{Script}' will not be run: unable to determine script executable. Update the script configuration, or set your operating system's SHELL envar."); } Log.Debug("Running script '{Script}': \"{Executable}\" {Args} (id: {ProcessId})", script.Key, executable, args, processId); -- cgit v1.2.3