-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Refactoring std os setenv #14736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactoring std os setenv #14736
Conversation
match os::setenv("RUST_TEST_TASKS","1") { | ||
Ok(()) => {}, | ||
Err(e) => { | ||
println!("Failed to use setenv: {}:", e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be better as fail!("
setenv failed: {}", e)
.
Error handling through std::io::IoResult.
The only documented error case on unix for Are there error cases for windows that we're worried about not catching? If it's just OOM then I'd tend to think that these functions should continue to return |
@alexcrichton: Funny on my Linux I have two errors documented. man setenv on Ubuntu 14.04:
And rustc is compiled with:
|
Ah yes, I also had |
So the best solution is to:
If somebody wants to write something like a shell in Rust it would be nice to have the possibility to check errors like theses instead of having a internal error. |
I would have to look at other functions as well, but failing on NUL is pretty common throughout the codebase, and it may be intentional rather than accidental. For now though, I'm going to close this pending further investigation. |
@alexcrichton https://gist.github.com/darnuria/9312f285ee8b265abf92 |
That is an interesting case! |
Simplifies the implementation a bit, also makes the message an error annotation changelog: none
Hello!
After talking with @huonw on Irc and trying different thing, I purpose to add a error handling over this wrapper of libc::setenv for catching errors.
I will need some help on the two commit marked as
fixup!
. I am still a newbie to rust. :)