From 76b99ff932a661adc512cb88cb6d1a78c485764a Mon Sep 17 00:00:00 2001 From: iff Date: Tue, 8 Aug 2023 10:40:47 +0200 Subject: [PATCH] fix: use `command -v` instead of which --- README.md | 2 +- rule_parser/src/lib.rs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cfb0201..4f15de1 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ pattern = [ "pattern 1", ] # this will add a `sudo` before the command if: -# - the `sudo` is found by `which` +# - the `sudo` is found by `command -v` # - the last command does not contain `sudo` suggest = [ ''' diff --git a/rule_parser/src/lib.rs b/rule_parser/src/lib.rs index df4574e..7e9e315 100644 --- a/rule_parser/src/lib.rs +++ b/rule_parser/src/lib.rs @@ -168,8 +168,9 @@ fn eval_condition(condition: &str, arg: &str) -> TokenStream2 { match condition { "executable" => { quote!{ - std::process::Command::new("which") - .arg(#arg) + std::process::Command::new(shell) + .arg("-c") + .arg(format!("command -v {}", #arg)) .output() .expect("failed to execute process") .status