Skip to content

Commit a2af155

Browse files
authored
- Implement drop on Commandeer to ensure PATH env variable is set to the original path. (#3)
Signed-off-by: William Johnson <[email protected]>
1 parent 00c5cf5 commit a2af155

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

commandeer-test/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,14 @@ exec env PATH="{}" {} {} --file {} --command {command_name} "$@"
236236
}
237237
}
238238

239+
impl Drop for Commandeer {
240+
fn drop(&mut self) {
241+
unsafe {
242+
std::env::set_var("PATH", &self.original_path);
243+
}
244+
}
245+
}
246+
239247
#[cfg(test)]
240248
mod tests {
241249
use crate as commandeer_test;

0 commit comments

Comments
 (0)