Skip to content

Commit

Permalink
fix(doctor): use a different method to detect env vars (#1819)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellie committed Mar 4, 2024
1 parent ede5a5f commit b115587
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions atuin/src/command/client/doctor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down

0 comments on commit b115587

Please sign in to comment.