fn final_or(cmd: &BasicCmd) {
    let fd = unsafe {
        // note that append won't work here because we only use the
        // '> out.file' functionality but not '>> out.file' which
        // would require the O_APPEND flag!

        // open() doesn't work; file remains empty
        // somehow fopen does some more magic..
        /*libc::open(
            cmd.out_red_path_cstring().unwrap().as_ptr(),
            libc::O_WRONLY | libc::O_CREAT,
            0644,
        );*/
        let file = libc::fopen(
            cmd.out_red_path_cstring().unwrap().as_ptr(),
            "w".as_ptr() as * const i8
        );
        // get file descriptor
        libc::fileno(file)
    };
    if fd == -1 {
        panic!("Output redirect path {} can't be opened/written! {}", cmd.out_red_path().as_ref().unwrap(), errno::errno());
    }
    let ret = unsafe { libc::dup2(fd, libc::STDOUT_FILENO) };
    if ret == -1 {
        panic!("Error dup2() output redirect! {}", errno::errno());
    }
}
/// Handles final output redirect (to file).
Handles final output redirect (to file).
Handles final output redirect ( to file ) .
fn final_or(cmd: &BasicCmd) {
    let fd = unsafe {
        // note that append won't work here because we only use the
        // '> out.file' functionality but not '>> out.file' which
        // would require the O_APPEND flag!
        // open() doesn't work; file remains empty
        // somehow fopen does some more magic..
        /*libc::open(
            cmd.out_red_path_cstring().unwrap().as_ptr(),
            libc::O_WRONLY | libc::O_CREAT,
            0644,
        );*/
        let file = libc::fopen(
            cmd.out_red_path_cstring().unwrap().as_ptr(),
            "w".as_ptr() as * const i8
        );
        // get file descriptor
        libc::fileno(file)
    };
    if fd == -1 {
        panic!("Output redirect path {} can't be opened/written! {}", cmd.out_red_path().as_ref().unwrap(), errno::errno());
    }
    let ret = unsafe { libc::dup2(fd, libc::STDOUT_FILENO) };
    if ret == -1 {
        panic!("Error dup2() output redirect! {}", errno::errno());
    }
}
fn final_or ( cmd : & BasicCmd ) { let fd = unsafe { // note that append won't work here because we only use the // '> out.file' functionality but not '>> out.file' which // would require the O_APPEND flag! // open() doesn't work; file remains empty // somehow fopen does some more magic.. /*libc::open(
            cmd.out_red_path_cstring().unwrap().as_ptr(),
            libc::O_WRONLY | libc::O_CREAT,
            0644,
        );*/ let file = libc :: fopen ( cmd . out_red_path_cstring ( ) . unwrap ( ) . as_ptr ( ) , " " . as_ptr ( ) as * const i8 ) ; // get file descriptor libc :: fileno ( file ) } ; if fd == - 1 { panic ! ( " " cmd out_red_path ( ) as_ref ( ) unwrap ( ) errno errno ( ) ) ; } let ret = unsafe { libc :: dup2 ( fd , libc :: STDOUT_FILENO ) } ; if ret == - 1 { panic ! ( " " errno errno ( ) ) ; } }
Handles final output redirect (to file).
Handles final output redirect ( to file ) .
cmd
&BasicCmd
cmd
&BasicCmd