From d9cedc891d0abc4c1411984fe5b820b170abea11 Mon Sep 17 00:00:00 2001 From: William Johnson Date: Thu, 21 Aug 2025 16:24:04 -0400 Subject: [PATCH] - Implement drop on Commandeer to ensure PATH env variable is set to the original path. Signed-off-by: William Johnson --- commandeer-test/src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/commandeer-test/src/lib.rs b/commandeer-test/src/lib.rs index 0e7aee9..079899a 100644 --- a/commandeer-test/src/lib.rs +++ b/commandeer-test/src/lib.rs @@ -236,6 +236,14 @@ exec env PATH="{}" {} {} --file {} --command {command_name} "$@" } } +impl Drop for Commandeer { + fn drop(&mut self) { + unsafe { + std::env::set_var("PATH", &self.original_path); + } + } +} + #[cfg(test)] mod tests { use crate as commandeer_test;