Skip to content

Specifying an env in run::ProcessOptions breaks finish_with_output #8028

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
catamorphism opened this issue Jul 24, 2013 · 3 comments
Closed

Comments

@catamorphism
Copy link
Contributor

use std::{io, os, run, str};

fn main() {

   let cwd = os::getcwd();
   let mut prog = run::Process::new("echo",
                                    [~"eggplants"],
                                    run::ProcessOptions { env: None,
                                                         dir: Some(&cwd),
                                                         in_fd: None,
                                                         out_fd: None,
                                                         err_fd: None
                                                        });
    let rslt = prog.finish_with_output();
    io::println(fmt!("status = %?; output = %s", rslt.status, str::from_bytes(rslt.output))); 
    assert_eq!(str::from_bytes(rslt.output), ~"eggplants\n");


    let mut prog = run::Process::new("echo",
                                     [~"$EGGPLANTS"],
                                     run::ProcessOptions { env: Some(&[(~"EGGPLANTS",
                                                                        ~"17")]),
                                                          dir: Some(&cwd),
                                                          in_fd: None,
                                                          out_fd: None,
                                                          err_fd: None
                                                         });
    let rslt = prog.finish_with_output();
    io::println(fmt!("status = %?; output = %s", rslt.status, str::from_bytes(rslt.output))); 
    assert_eq!(str::from_bytes(rslt.output), ~"17");
}

The second assertion fails. Also, the "echo" process fails with exit code 1. Something about putting a Some(...) in the env field is breaking process spawning.

This is on Mac OS X; I don't know about other platforms.

@catamorphism
Copy link
Contributor Author

This is using revision 330378d , btw.

@catamorphism
Copy link
Contributor Author

Maybe related to #8498. I'll test this again after #8518 lands.

@alexcrichton
Copy link
Member

Closing, this has been fixed in the interim, and I highly suspect that fixes to codegen have caused this to be un-broken.

Closing as I believe the test case from #9259 is sufficient

flip1995 pushed a commit to flip1995/rust that referenced this issue Dec 2, 2021
Add more descriptive help info for `needless_question_mark`

closes rust-lang#8016

changelog: [`needless_question_mark`] help suggestion now explains what should be changed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants