summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChloe M <chloe@faracom.org>2026-08-16 17:51:44 -0500
committerChloe M <chloe@faracom.org>2026-08-16 17:51:44 -0500
commitc846f4140c2b717487c3588279ba4c2816f21487 (patch)
tree653e7f5f6e753d14eb95048f15d45b1586a07023
parent2874b28d8b8a00e6ad3f8f54bde25d98f86f4719 (diff)
core: hook: Try to use current shell, fallback on failure
Signed-off-by: Chloe M <chloe@faracom.org>
-rw-r--r--core/hook.c19
1 files changed, 17 insertions, 2 deletions
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 <sys/wait.h>
+#include <stdlib.h>
#include <unistd.h>
+#include <stdio.h>
#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)