summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)