Repository: gitui-org/gitui (language: rust)

Issue:
Use default shell for git-hooks instead of bash
Would it be possible to run the hooks with the shell specified by `$SHELL` instead of defaulting to bash here? If I understand correctly, it matters when running from a non-login (e.g. gui application) shell since bash won't inherit desired environment variables.

https://github.com/extrawurst/gitui/blob/4ef633a75a3581936d0da9aade7af8ed7aad98ab/git2-hooks/src/hookspath.rs#L116-L117



Discussion / hints:
zsh is the default shell on macOS these days.

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7c24f38357..2593b46b7c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ## Unreleased
 
+### Breaking Changes
+
+#### Shell
+* use default shell instead of bash on Unix-like OS [[@yerke](https://github.com/yerke)] ([#2343](https://github.com/extrawurst/gitui/pull/2343))
+
 ### Fixes
 * respect env vars like `GIT_CONFIG_GLOBAL` ([#2298](https://github.com/extrawurst/gitui/issues/2298))
 
diff --git a/git2-hooks/src/hookspath.rs b/git2-hooks/src/hookspath.rs
index 714ef81d10..fe01386b4e 100644
--- a/git2-hooks/src/hookspath.rs
+++ b/git2-hooks/src/hookspath.rs
@@ -3,7 +3,7 @@ use git2::Repository;
 use crate::{error::Result, HookResult, HooksError};
 
 use std::{
-	path::Path, path::PathBuf, process::Command, str::FromStr,
+	env, path::Path, path::PathBuf, process::Command, str::FromStr,
 };
 
 pub struct HookPaths {
@@ -113,9 +113,10 @@ impl HookPaths {
 
 		log::trace!("run hook '{:?}' in '{:?}'", hook, self.pwd);
 
-		let git_bash = find_bash_executable()
-			.unwrap_or_else(|| PathBuf::from("bash"));
-		let output = Command::new(git_bash)
+		let git_shell = find_bash_executable()
+			.or_else(find_default_unix_shell)
+			.unwrap_or_else(|| "bash".into());
+		let output = Command::new(git_shell)
 			.args(bash_args)
 			.current_dir(&self.pwd)
 			// This call forces Command to handle the Path environment correctly on windows,
@@ -191,3 +192,8 @@ fn find_bash_executable() -> Option<PathBuf> {
 		None
 	}
 }
+
+// Find default shell on Unix-like OS.
+fn find_default_unix_shell() -> Option<PathBuf> {
+	env::var_os("SHELL").map(PathBuf::from)
+}


Test patch: