Skip to content

Commit

Permalink
Implement private function to get version on illumos
Browse files Browse the repository at this point in the history
  • Loading branch information
martintc committed Apr 25, 2022
1 parent d4b3fae commit 9dfb195
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion os_info/src/illumos/mod.rs
Expand Up @@ -8,7 +8,7 @@ use crate::{bitness, uname::uname, Info, Type, Version};
pub fn current_platform() -> Info {
trace!("illumos::current_platform is called");

let version = uname()
let version = get_version()
.map(Version::from_string)
.unwrap_or_else(|| Version::Unknown);

Expand All @@ -23,6 +23,24 @@ pub fn current_platform() -> Info {
info
}

fn get_version() -> Option<String> {
Command::new("uname")
.arg("-v")
.output()
.map_err(|e| {
error!("Failed to invoke 'uname': {:?}", e);
})
.ok()
.and_then(|out| {
if out.status.success() {
Some(String::from_utf8_lossy(&out.stdout).trim_end().to_owned())
} else {
log::error!("'uname' invocation error: {:?}", out);
None
}
})
}

fn get_os() -> Type {
let os = Command::new("uname")
.arg("-o")
Expand Down

0 comments on commit 9dfb195

Please sign in to comment.