Skip to content

Check for BSDs #34

@rgeorgia

Description

@rgeorgia

We could add support of BSD by invoking uname -s and uname -a. Now, I am so new to Rust I can barely spell it. I am not even sure how I can add this to os_type to test it out. Any hand holding would be accepted. Here is what I have. It works for NetBSD, OpenBSD, FreeBSD, well any BSD derivative.
fn get_os_bsd() {

let nb_output = Command::new("uname").arg("-s").output()
    .expect("failed to execute uname") ;

println!("OS stdout: {}", String::from_utf8_lossy(&nb_output.stdout)) ;

}

fn get_bsd_version() {

let nb_output = Command::new("uname").arg("-r").output()
    .expect("failed to execute uname") ;

println!("Version stdout: {}", String::from_utf8_lossy(&nb_output.stdout)) ;

}

OUTPUT:
Mac (our solution much better)
OS stdout: Darwin
Version stdout: 18.2.0

NetBSD:
OS stdout: NetBSD
Version stdout: 8.99.35

FreeBSD:
OS stdout: FreeBSD
Version stdout: 12.0-RELEASE

OpenBSD:
OS stdout: OpenBSD
Version stdout: 6.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions