The documentation doesn't seem to mention how shellfn handles stderr. I did some experimenting and it looked like stderr is just inherited and goes straight to the terminal. It would be nice if stderr could be captured and suppressed or handled however the caller desires.
What I'm trying to do is make a temporary commit and return the sha, and if there's an error I would like to have an informative error message. My first attempt was to pipe all stdout output other than the sha itself to stderr with the assumption that the Box type returned by shellfn would somehow contain that stderr content which I could print to act as an informative error message. Instead, all of that output went to the terminal, I got the sha correctly, but it caused a lot of output I didn't want to see. So I hacked around it by piping all that output to a temp file and cating that to stderr if the script exited with an error status.
In the past, I've been using the shells crate which has the following Error type, https://docs.rs/shells/0.2.0/shells/struct.Error.html. Having an option to get an error vaguely like this would be useful I think.
The documentation doesn't seem to mention how shellfn handles stderr. I did some experimenting and it looked like stderr is just inherited and goes straight to the terminal. It would be nice if stderr could be captured and suppressed or handled however the caller desires.
Heres the example I played with.
What I'm trying to do is make a temporary commit and return the sha, and if there's an error I would like to have an informative error message. My first attempt was to pipe all stdout output other than the sha itself to stderr with the assumption that the Box type returned by shellfn would somehow contain that stderr content which I could print to act as an informative error message. Instead, all of that output went to the terminal, I got the sha correctly, but it caused a lot of output I didn't want to see. So I hacked around it by piping all that output to a temp file and cating that to stderr if the script exited with an error status.
In the past, I've been using the
shells
crate which has the following Error type, https://docs.rs/shells/0.2.0/shells/struct.Error.html. Having an option to get an error vaguely like this would be useful I think.