Skip to content
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

Check for BSDs #34

Open
rgeorgia opened this issue Mar 20, 2019 · 1 comment
Open

Check for BSDs #34

rgeorgia opened this issue Mar 20, 2019 · 1 comment

Comments

@rgeorgia
Copy link

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

@rgeorgia
Copy link
Author

DragonFlyBSD:
OS stdout: DragonFly
Version stdout: 5.4-RELEASE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant