diff options
| author | JP Dillingham <jp@dillingham.me> | 2025-02-16 17:38:36 -0600 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2025-02-16 17:38:36 -0600 |
| commit | e6d927beabe38eef8d184ccdf5f914026a272255 (patch) | |
| tree | 061625de8816e24b6a7ebe646f448b9d294e3c45 /src | |
| parent | 94d46b3eb94c3f846b84afe9e58c651b8c63616d (diff) | |
| download | slskd-e6d927beabe38eef8d184ccdf5f914026a272255.tar.gz | |
set DefaultExecutable
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Integrations/Scripts/ScriptService.cs | 17 |
1 files changed, 16 insertions, 1 deletions
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<Event>(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<ScriptService>(); private IOptionsMonitor<Options> 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) { |
