File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77
88use clap:: Command ;
99use libc:: { c_long, gethostid} ;
10+ use std:: io:: { Write , stdout} ;
1011use uucore:: { error:: UResult , format_usage} ;
1112
1213use uucore:: translate;
1314
1415#[ uucore:: main]
1516pub fn uumain ( args : impl uucore:: Args ) -> UResult < ( ) > {
1617 uucore:: clap_localization:: handle_clap_result ( uu_app ( ) , args) ?;
17- hostid ( ) ;
18- Ok ( ( ) )
19- }
20-
21- pub fn uu_app ( ) -> Command {
22- Command :: new ( uucore:: util_name ( ) )
23- . version ( uucore:: crate_version!( ) )
24- . help_template ( uucore:: localized_help_template ( uucore:: util_name ( ) ) )
25- . about ( translate ! ( "hostid-about" ) )
26- . override_usage ( format_usage ( & translate ! ( "hostid-usage" ) ) )
27- . infer_long_args ( true )
28- }
29-
30- fn hostid ( ) {
3118 /*
3219 * POSIX says gethostid returns a "32-bit identifier" but is silent
3320 * whether it's sign-extended. Turn off any sign-extension. This
@@ -43,5 +30,15 @@ fn hostid() {
4330 let mask = 0xffff_ffff ;
4431
4532 result &= mask;
46- println ! ( "{result:0>8x}" ) ;
33+ writeln ! ( stdout( ) . lock( ) , "{result:0>8x}" ) ?;
34+ Ok ( ( ) )
35+ }
36+
37+ pub fn uu_app ( ) -> Command {
38+ Command :: new ( uucore:: util_name ( ) )
39+ . version ( uucore:: crate_version!( ) )
40+ . help_template ( uucore:: localized_help_template ( uucore:: util_name ( ) ) )
41+ . about ( translate ! ( "hostid-about" ) )
42+ . override_usage ( format_usage ( & translate ! ( "hostid-usage" ) ) )
43+ . infer_long_args ( true )
4744}
You can’t perform that action at this time.
0 commit comments