minor fixes to main()

This commit is contained in:
Emma Tebibyte 2023-04-14 14:53:55 -04:00
parent d68a719a90
commit 64249e0f67
1 changed files with 3 additions and 4 deletions

View File

@ -472,12 +472,12 @@ fn main() -> Result<()> {
if unsafe { libc::isatty(stdin) } == 0 {
unsafe { File::from_raw_fd(stdin) }
} else {
File::open("/dev/null").unwrap()
File::open("/dev/null")?
}
}
Some(path) => {
let input_file = Path::new(path);
file_name = Some(OsString::from(input_file.clone().display().to_string()));
file_name = Some(OsString::from(&path));
File::open(input_file).unwrap_or_else(|_| {
let mut err = String::new();
@ -491,8 +491,7 @@ fn main() -> Result<()> {
})
}
}
.read_to_end(&mut buf)
.unwrap();
.read_to_end(&mut buf)?;
let text = String::from_utf8(buf).unwrap_or_else(|_| {
eprintln!(