mirror of
https://github.com/extrawurst/gitui.git
synced 2024-12-25 18:13:34 +03:00
Use default shell instead of bash on Unix-like OS
This commit is contained in:
parent
63a91fd281
commit
4cb9500cd9
@ -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))
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user