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