File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ use crate::params::{parse_params, Format};
77use std:: env;
88use std:: ffi:: OsString ;
99use std:: fs;
10- use std:: io:: { self , Write } ;
10+ use std:: io:: { self , Read , Write } ;
1111use std:: process:: { exit, ExitCode } ;
1212
1313mod context_diff;
@@ -46,8 +46,12 @@ fn main() -> ExitCode {
4646 }
4747 // read files
4848 fn read_file_contents ( filepath : & OsString ) -> io:: Result < Vec < u8 > > {
49- let stdin = OsString :: from ( "/dev/stdin" ) ;
50- fs:: read ( if filepath == "-" { & stdin } else { filepath } )
49+ if filepath == "-" {
50+ let mut content = Vec :: new ( ) ;
51+ io:: stdin ( ) . read_to_end ( & mut content) . and ( Ok ( content) )
52+ } else {
53+ fs:: read ( filepath)
54+ }
5155 }
5256 let from_content = match read_file_contents ( & params. from ) {
5357 Ok ( from_content) => from_content,
You can’t perform that action at this time.
0 commit comments