yac
/
coreutils
Archived
2
0
Fork 0

cat(1): fixed pseudo-unbuffered output

This commit is contained in:
Emma Tebibyte 2022-12-12 18:55:15 -05:00
parent c5123b9d19
commit 3e555542b6
1 changed files with 4 additions and 6 deletions

View File

@ -53,11 +53,7 @@ fn main() -> ExitCode {
if path == "-" {
loop {
match io::stdin().lock().read_line(&mut output) {
Ok(EOF) => {
print!("{}", output);
output.clear();
if EOF == 0 { break }
},
Ok(EOF) => if EOF == 0 { break },
Err(_) => {
eprintln!("Usage: {} [options...] [files...]", &argv0);
return ExitCode::Usage;
@ -66,13 +62,15 @@ fn main() -> ExitCode {
}
} else {
match read_to_string(&path) {
Ok(output) => print!("{}", output),
Ok(output) => {},
Err(_) => {
eprintln!("{}: {}: No such file or directory.", &argv0, &path);
return ExitCode::NoInput;
},
};
}
print!("{}", output);
output.clear();
}
match io::stdout().flush() {
Ok(_) => return ExitCode::Ok,