1313use clap:: { crate_version, Arg , ArgAction , Command } ;
1414use platform_info:: * ;
1515use 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 {
3636pub 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