Skip to content

Commit

Permalink
🐛 fix: 0.7.1: Don't crash when which fails at binary comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
queer committed May 7, 2023
1 parent ee160d6 commit 9e19bb7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "boxxy"
version = "0.7.0"
version = "0.7.1"
edition = "2021"
repository = "https://github.com/queer/boxxy"

Expand Down
14 changes: 11 additions & 3 deletions src/enclosure/rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,18 @@ impl Rule {
}

// Resolve both program and rule_binary with `which` and compare. ex. /usr/bin/ls == /usr/bin/ls
let which_rule_binary = which::which(rule_binary)?;
let which_user_program = which::which(program)?;
let which_rule_binary = match which::which(rule_binary) {
Ok(which_rule_binary) => Some(which_rule_binary),
Err(_) => None,
};
let which_user_program = match which::which(program) {
Ok(which_user_program) => Some(which_user_program),
Err(_) => None,
};
debug!("{}: comparing binaries with which(1): which_user_program={which_user_program:?}, which_rule_binary={which_rule_binary:?}", self.name);
if which_rule_binary == which_user_program {
if which_rule_binary == which_user_program
&& (which_rule_binary.is_some() || which_user_program.is_some())
{
return Ok(true);
}

Expand Down

0 comments on commit 9e19bb7

Please sign in to comment.