From c228686df9024f9a4475fe5f596a7dbfe56c4bc6 Mon Sep 17 00:00:00 2001 From: Michael Hall Date: Sat, 2 Dec 2023 07:56:24 +1000 Subject: [PATCH] fix: make is_executable more portable --- .github/workflows/ci.yaml | 2 +- src/lib.rs | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 518ac7a..6137106 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -56,7 +56,7 @@ jobs: - name: Run tests env: - RUST_BACKTRACE: "1" + RUST_BACKTRACE: "full" run: just test - uses: taiki-e/install-action@v2 diff --git a/src/lib.rs b/src/lib.rs index e285239..1fca52d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -42,11 +42,12 @@ impl CommandRunner { } pub fn is_executable(&self) -> bool { - Command::new("command") - .args(["-v", &self.command]) - .output() - .map(|output| output.status.success()) - .unwrap_or(false) + let cmd = format!("command -v {}", &self.command); + let result = Command::new("sh").args(["-c", &cmd]).output(); + match result { + Ok(output) => output.status.success(), + Err(_) => false, + } } }