forked from mars/breed
cargo fmt
This commit is contained in:
parent
8a110c5b01
commit
f5ea473328
32
src/main.rs
32
src/main.rs
|
@ -20,12 +20,7 @@
|
|||
use std::{
|
||||
env::args,
|
||||
fs::File,
|
||||
io::{
|
||||
Read,
|
||||
stdout,
|
||||
Stdout,
|
||||
Write,
|
||||
},
|
||||
io::{stdout, Read, Stdout, Write},
|
||||
os::fd::FromRawFd,
|
||||
};
|
||||
|
||||
|
@ -463,23 +458,22 @@ fn main() -> Result<()> {
|
|||
let stdin = 0; // get stdin as a file descriptor
|
||||
if unsafe { libc::isatty(stdin) } == 0 {
|
||||
unsafe { File::from_raw_fd(stdin) }
|
||||
} else { File::open("/dev/null").unwrap() }
|
||||
},
|
||||
Some(path) => {
|
||||
std::fs::File::open(path).unwrap_or_else(|_| {
|
||||
eprintln!(
|
||||
"{}: {}: No such file or directory.",
|
||||
argv[0],
|
||||
argv[1]
|
||||
);
|
||||
} else {
|
||||
File::open("/dev/null").unwrap()
|
||||
}
|
||||
}
|
||||
Some(path) => std::fs::File::open(path).unwrap_or_else(|_| {
|
||||
eprintln!("{}: {}: No such file or directory.", argv[0], argv[1]);
|
||||
exit(EX_UNAVAILABLE);
|
||||
})
|
||||
},
|
||||
}.read_to_end(&mut buf).unwrap();
|
||||
}),
|
||||
}
|
||||
.read_to_end(&mut buf)
|
||||
.unwrap();
|
||||
|
||||
let text = String::from_utf8(buf).unwrap_or_else(|_| {
|
||||
eprintln!(
|
||||
"{}: {}: File contents are not valid UTF-8.", argv[0], argv[1]
|
||||
"{}: {}: File contents are not valid UTF-8.",
|
||||
argv[0], argv[1]
|
||||
);
|
||||
exit(EX_DATAERR);
|
||||
});
|
||||
|
|
Reference in New Issue
Block a user