Skip to content

Commit f830b6e

Browse files
committed
update to platform-info 2.0.1
1 parent 4f89d86 commit f830b6e

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ onig = { version = "~6.4", default-features = false }
304304
ouroboros = "0.15.6"
305305
phf = "0.11.1"
306306
phf_codegen = "0.11.1"
307-
platform-info = "1.0.2"
307+
platform-info = "2.0.1"
308308
quick-error = "2.0.1"
309309
rand = { version = "0.8", features = ["small_rng"] }
310310
rand_core = "0.6"

src/uu/arch/src/arch.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use platform_info::*;
1010

1111
use clap::{crate_version, Command};
12-
use uucore::error::{FromIo, UResult};
12+
use uucore::error::{UResult, USimpleError};
1313
use uucore::{help_about, help_section};
1414

1515
static ABOUT: &str = help_about!("arch.md");
@@ -19,8 +19,9 @@ static SUMMARY: &str = help_section!("after help", "arch.md");
1919
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
2020
uu_app().try_get_matches_from(args)?;
2121

22-
let uts = PlatformInfo::new().map_err_context(|| "cannot get system name".to_string())?;
23-
println!("{}", uts.machine().trim());
22+
let uts = PlatformInfo::new().map_err(|_e| USimpleError::new(1, "cannot get system name"))?;
23+
24+
println!("{}", uts.machine().to_string_lossy().trim());
2425
Ok(())
2526
}
2627

src/uu/uname/src/uname.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use clap::{crate_version, Arg, ArgAction, Command};
1414
use platform_info::*;
1515
use uucore::{
16-
error::{FromIo, UResult},
16+
error::{UResult, USimpleError},
1717
format_usage, help_about, help_usage,
1818
};
1919

@@ -36,8 +36,8 @@ pub mod options {
3636
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
3737
let matches = uu_app().try_get_matches_from(args)?;
3838

39-
let uname =
40-
PlatformInfo::new().map_err_context(|| "failed to create PlatformInfo".to_string())?;
39+
let uname = PlatformInfo::new().map_err(|_e| USimpleError::new(1, "cannot get system name"))?;
40+
4141
let mut output = String::new();
4242

4343
let all = matches.get_flag(options::ALL);
@@ -61,33 +61,32 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
6161
|| hardware_platform);
6262

6363
if kernel_name || all || none {
64-
output.push_str(&uname.sysname());
64+
output.push_str(&uname.sysname().to_string_lossy());
6565
output.push(' ');
6666
}
6767

6868
if nodename || all {
69-
// maint: [2023-01-14; rivy] remove `.trim_end_matches('\0')` when platform-info nodename-NUL bug is fixed (see GH:uutils/platform-info/issues/32)
70-
output.push_str(uname.nodename().trim_end_matches('\0'));
69+
output.push_str(&uname.nodename().to_string_lossy());
7170
output.push(' ');
7271
}
7372

7473
if kernel_release || all {
75-
output.push_str(&uname.release());
74+
output.push_str(&uname.release().to_string_lossy());
7675
output.push(' ');
7776
}
7877

7978
if kernel_version || all {
80-
output.push_str(&uname.version());
79+
output.push_str(&uname.version().to_string_lossy());
8180
output.push(' ');
8281
}
8382

8483
if machine || all {
85-
output.push_str(&uname.machine());
84+
output.push_str(&uname.machine().to_string_lossy());
8685
output.push(' ');
8786
}
8887

8988
if os || all {
90-
output.push_str(&uname.osname());
89+
output.push_str(&uname.osname().to_string_lossy());
9190
output.push(' ');
9291
}
9392

0 commit comments

Comments
 (0)