Skip to content

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

Closed
@catamorphism

Description

@catamorphism
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions