1
1
mirror of https://github.com/ellie/atuin.git synced 2024-10-27 07:40:53 +03:00

fix(doctor): use a different method to detect env vars (#1819)

This commit is contained in:
Ellie Huxtable 2024-03-04 17:50:30 +00:00 committed by GitHub
parent ede5a5febf
commit b1155873dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -25,17 +25,18 @@ impl ShellInfo {
//
// Every shell we support handles `shell -c 'command'`
fn env_exists(shell: &str, var: &str) -> bool {
let mut cmd = Command::new(shell)
.args(["-ic", format!("echo ${var}").as_str()])
let cmd = Command::new(shell)
.args([
"-ic",
format!("[ -z ${var} ] || echo ATUIN_DOCTOR_ENV_FOUND").as_str(),
])
.output()
.map_or(String::new(), |v| {
let out = v.stdout;
String::from_utf8(out).unwrap_or_default()
});
cmd.retain(|c| !c.is_whitespace());
!cmd.is_empty()
cmd.contains("ATUIN_DOCTOR_ENV_FOUND")
}
pub fn plugins(shell: &str) -> Vec<String> {