From e6d927beabe38eef8d184ccdf5f914026a272255 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 16 Feb 2025 17:38:36 -0600 Subject: set DefaultExecutable --- src/slskd/Integrations/Scripts/ScriptService.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/slskd/Integrations/Scripts') diff --git a/src/slskd/Integrations/Scripts/ScriptService.cs b/src/slskd/Integrations/Scripts/ScriptService.cs index 28c8db77..b3092a56 100644 --- a/src/slskd/Integrations/Scripts/ScriptService.cs +++ b/src/slskd/Integrations/Scripts/ScriptService.cs @@ -39,13 +39,28 @@ public class ScriptService Events.Subscribe(nameof(ScriptService), HandleEvent); + if (OperatingSystem.IsWindows()) + { + DefaultExecutable = "cmd.exe"; + } + else + { + DefaultExecutable = Environment.GetEnvironmentVariable("SHELL"); + + if (string.IsNullOrEmpty(DefaultExecutable)) + { + Log.Warning("Unable to determine default script executable ($SHELL is missing or blank); any user-defined scripts that do not specify an executable will fail"); + } + } + + Log.Information("Set default script executable to '{DefaultExecutable}'", DefaultExecutable); Log.Debug("{Service} initialized", nameof(ScriptService)); } private ILogger Log { get; } = Serilog.Log.ForContext(); private IOptionsMonitor OptionsMonitor { get; } private EventBus Events { get; } - private Regex LeadingQuotedString => new("(\"[^\"]*\"){0,1}(.*)", RegexOptions.Singleline | RegexOptions.Compiled); + private string DefaultExecutable { get; } private async Task HandleEvent(Event data) { -- cgit v1.2.3