oconnor663 / duct.rs

a Rust library for running child processes
MIT License
795 stars 34 forks source link

Set environment variables before running sh or sh_dangerous command #87

Closed wickedchicken closed 4 years ago

wickedchicken commented 4 years ago

Hey, thanks for duct_sh!

I was wondering if it would be possible to add envars to be set when calling a command through sh() or sh_dangerous(). My use case is a "local CI" command runner which runs a provided list of checks whenever invoked. These tests often need envars set, for example to set dummy database locations or to enable debug logging. While it's possible to embed strings into the shell commands themselves to set the environment variables, duct has native envar support which seems much cleaner.

Thanks!

oconnor663 commented 4 years ago

duct_sh is intended to be used with all the underlying features of duct, including the .env(...) method. The sh and sh_dangerous functions return a duct::Expression, so everything should Just Work. Could you give it a try and let me know if it works for you?

wickedchicken commented 4 years ago

Indeed, it does! Sorry for the noise, and thanks for the library!

oconnor663 commented 4 years ago

No problem! Always glad to have users :)