We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 12ff191 commit 22e2ab3Copy full SHA for 22e2ab3
src/lib.rs
@@ -17,7 +17,13 @@ pub fn username() -> String {
17
18
#[cfg(target_family = "unix")]
19
pub fn hostname() -> Result<String, ()> {
20
- Ok(var("HOSTNAME").unwrap())
+ let output = Command::new("hostname")
21
+ .output();
22
+
23
+ match output {
24
+ Ok(output) => return Ok(String::from_utf8(output.stdout).unwrap()),
25
+ Err(_) => return Err(()),
26
+ }
27
}
28
29
#[cfg(target_family = "windows")]
@@ -135,4 +141,4 @@ macro_rules! printlnr {
135
141
($($arg:tt)*) => ({
136
142
println!("{}\x1b[0m", format_args!($($arg)*));
137
143
})
138
-}
144
+}
0 commit comments