We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6dc34fe commit 84ad116Copy full SHA for 84ad116
1 file changed
src/main.rs
@@ -7,7 +7,7 @@ use crate::params::{parse_params, Format};
7
use std::env;
8
use std::ffi::OsString;
9
use std::fs;
10
-use std::io::{self, Write};
+use std::io::{self, Read, Write};
11
use std::process::{exit, ExitCode};
12
13
mod context_diff;
@@ -46,8 +46,12 @@ fn main() -> ExitCode {
46
}
47
// read files
48
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 })
+ if filepath == "-" {
+ let mut content = Vec::new();
51
+ io::stdin().read_to_end(&mut content).and(Ok(content))
52
+ } else {
53
+ fs::read(filepath)
54
+ }
55
56
let from_content = match read_file_contents(¶ms.from) {
57
Ok(from_content) => from_content,
0 commit comments