evobench_tools/io_utils/
shell.rs

1use anyhow::{Result, bail};
2
3/// Returns what `$SHELL` is set to, or otherwise `bash`
4pub fn preferred_shell() -> Result<String> {
5    match std::env::var("SHELL") {
6        Ok(s) => Ok(s),
7        Err(e) => match e {
8            std::env::VarError::NotPresent => Ok("bash".into()),
9            std::env::VarError::NotUnicode(os_string) => {
10                bail!("the SHELL environment variable is not in unicode: {os_string:?}")
11            }
12        },
13    }
14}