Skip to content

Commit 524e3d8

Browse files
committed
Use default shell instead of bash on Unix-like OS
1 parent 63a91fd commit 524e3d8

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
### Breaking Changes
11+
12+
#### Shell
13+
* use default shell instead of bash on Unix-like OS [[@yerke](https://github.com/yerke)] ([#2343](https://github.com/extrawurst/gitui/pull/2343))
14+
1015
### Fixes
1116
* respect env vars like `GIT_CONFIG_GLOBAL` ([#2298](https://github.com/extrawurst/gitui/issues/2298))
1217

git2-hooks/src/hookspath.rs

+11-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use git2::Repository;
33
use crate::{error::Result, HookResult, HooksError};
44

55
use std::{
6-
path::Path, path::PathBuf, process::Command, str::FromStr,
6+
env, path::Path, path::PathBuf, process::Command, str::FromStr,
77
};
88

99
pub struct HookPaths {
@@ -113,9 +113,11 @@ impl HookPaths {
113113

114114
log::trace!("run hook '{:?}' in '{:?}'", hook, self.pwd);
115115

116-
let git_bash = find_bash_executable()
117-
.unwrap_or_else(|| PathBuf::from("bash"));
118-
let output = Command::new(git_bash)
116+
let git_shell = find_bash_executable().unwrap_or_else(|| {
117+
find_default_unix_shell()
118+
.unwrap_or_else(|| PathBuf::from("bash"))
119+
});
120+
let output = Command::new(git_shell)
119121
.args(bash_args)
120122
.current_dir(&self.pwd)
121123
// This call forces Command to handle the Path environment correctly on windows,
@@ -191,3 +193,8 @@ fn find_bash_executable() -> Option<PathBuf> {
191193
None
192194
}
193195
}
196+
197+
// Find default shell on Unix-like OS.
198+
fn find_default_unix_shell() -> Option<PathBuf> {
199+
env::var_os("SHELL").map(PathBuf::from)
200+
}

0 commit comments

Comments
 (0)