cat(1): fixed pseudo-unbuffered output
This commit is contained in:
parent
c5123b9d19
commit
3e555542b6
10
src/cat.rs
10
src/cat.rs
@ -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,
|
||||
|
Reference in New Issue
Block a user