mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-12 06:20:09 +01:00
fix: check executable in nushell
This commit is contained in:
parent
c2708a4de5
commit
6a06aa5954
3 changed files with 26 additions and 12 deletions
|
|
@ -44,6 +44,30 @@ fn match_pattern(
|
|||
parse_rules!("rules");
|
||||
}
|
||||
|
||||
fn check_executable(shell: &str, executable: &str) -> bool {
|
||||
match shell {
|
||||
"nu" => {
|
||||
std::process::Command::new(shell)
|
||||
.arg("-c")
|
||||
.arg(format!("if (which {} | is-empty) {{ exit 1 }}", executable))
|
||||
.output()
|
||||
.expect("failed to execute process")
|
||||
.status
|
||||
.success()
|
||||
}
|
||||
_ => {
|
||||
std::process::Command::new(shell)
|
||||
.arg("-c")
|
||||
.arg(format!("command -v {}", executable))
|
||||
.output()
|
||||
.expect("failed to execute process")
|
||||
.status
|
||||
.success()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fn opt_regex(regex: &str, command: &mut String) -> String {
|
||||
let regex = Regex::new(regex).unwrap();
|
||||
let opts = regex
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue