@@ -30,7 +30,7 @@ use std::os::unix::ffi::OsStrExt;
3030#[ cfg( unix) ]
3131use std:: os:: unix:: process:: CommandExt ;
3232
33- use uucore:: display:: Quotable ;
33+ use uucore:: display:: { OsWrite , Quotable } ;
3434use uucore:: error:: { ExitCode , UError , UResult , USimpleError , UUsageError } ;
3535use uucore:: line_ending:: LineEnding ;
3636#[ cfg( unix) ]
@@ -100,12 +100,16 @@ struct Options<'a> {
100100}
101101
102102/// print `name=value` env pairs on screen
103- fn print_env ( line_ending : LineEnding ) {
103+ fn print_env ( line_ending : LineEnding ) -> io :: Result < ( ) > {
104104 let stdout_raw = io:: stdout ( ) ;
105105 let mut stdout = stdout_raw. lock ( ) ;
106- for ( n, v) in env:: vars ( ) {
107- write ! ( stdout, "{n}={v}{line_ending}" ) . unwrap ( ) ;
106+ for ( n, v) in env:: vars_os ( ) {
107+ stdout. write_all_os ( & n) ?;
108+ stdout. write_all ( b"=" ) ?;
109+ stdout. write_all_os ( & v) ?;
110+ write ! ( stdout, "{line_ending}" ) ?;
108111 }
112+ Ok ( ( ) )
109113}
110114
111115fn parse_name_value_opt < ' a > ( opts : & mut Options < ' a > , opt : & ' a OsStr ) -> UResult < bool > {
@@ -548,7 +552,7 @@ impl EnvAppData {
548552
549553 if opts. program . is_empty ( ) {
550554 // no program provided, so just dump all env vars to stdout
551- print_env ( opts. line_ending ) ;
555+ print_env ( opts. line_ending ) ? ;
552556 } else {
553557 return self . run_program ( & opts, self . do_debug_printing ) ;
554558 }
0 commit comments