Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,23 @@ fn read_input(file: &Option<String>) -> Vec<u8> {
match file.as_deref() {
Some(path) if path != "-" => {
File::open(path)
.unwrap_or_else(|e| panic!("cannot open '{}': {}", path, e))
.unwrap_or_else(|e| {
eprintln!("cannot open '{}': {}", path, e);
std::process::exit(1);
})
.read_to_end(&mut data)
.unwrap_or_else(|e| panic!("read error: {}", e));
.unwrap_or_else(|e| {
eprintln!("read error: {}", e);
std::process::exit(1);
});
}
_ => {
io::stdin()
.read_to_end(&mut data)
.unwrap_or_else(|e| panic!("read error: {}", e));
.unwrap_or_else(|e| {
eprintln!("read error: {}", e);
std::process::exit(1);
});
}
};
data
Expand Down
Loading