From c846f4140c2b717487c3588279ba4c2816f21487 Mon Sep 17 00:00:00 2001 From: Chloe M Date: Sun, 16 Aug 2026 17:51:44 -0500 Subject: core: hook: Try to use current shell, fallback on failure Signed-off-by: Chloe M --- core/hook.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'core/hook.c') diff --git a/core/hook.c b/core/hook.c index b915901..b2f3a2e 100644 --- a/core/hook.c +++ b/core/hook.c @@ -4,7 +4,9 @@ */ #include +#include #include +#include #include "bop/hook.h" /* Shell we use by default */ @@ -18,17 +20,30 @@ static void exec_shell_for(const char *script_path) { + char *shell_path; + if (script_path == NULL) { return; } - execl(DEFAULT_SHELL_PATH, DEFAULT_SHELL_PATH, script_path, NULL); + /* + * We will attempt to use the current shell but if we cannot determine it, + * we will then fallback to the default shell path. + */ + shell_path = getenv("SHELL"); + if (shell_path == NULL) { + shell_path = DEFAULT_SHELL_PATH; + printf("warning: could not determine shell\n"); + printf("warning: falling back to '%s'\n", shell_path); + } + + execl(shell_path, shell_path, script_path, NULL); } /* * Run a shell hook with POSIX sh * - * XXX: Maybe support '#!/bin/xxx'? + * XXX: Maybe support '#!/bin/xxx'? */ int bop_shell_hook(const char *hook_path) -- cgit v1.2.3