diff options
| author | JP Dillingham <jp@dillingham.me> | 2025-02-16 17:39:05 -0600 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2025-02-16 17:39:05 -0600 |
| commit | 6620aaf1bd072b8e86adc0a1541109cb51506e28 (patch) | |
| tree | 762a9fe0b4508c596bd382b8986c90e628d9e13d /src/slskd/Integrations/Scripts | |
| parent | e6d927beabe38eef8d184ccdf5f914026a272255 (diff) | |
| download | slskd-6620aaf1bd072b8e86adc0a1541109cb51506e28.tar.gz | |
fall back to DefaultExecutable if none specified
Diffstat (limited to 'src/slskd/Integrations/Scripts')
| -rw-r--r-- | src/slskd/Integrations/Scripts/ScriptService.cs | 24 |
1 files changed, 4 insertions, 20 deletions
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); |
