Exit on STDIN EOF

This commit is contained in:
pjht 2024-11-20 14:00:15 -06:00
parent f176bdce91
commit 9002fa3b35
Signed by: pjht
GPG Key ID: CA239FC6934E6F3A

View File

@ -1,5 +1,5 @@
use std::{
env::{current_dir, set_current_dir}, io::{self, Write}, path::{Component, Path, PathBuf}, process::Command
env::{current_dir, set_current_dir}, io::{self, Write}, path::PathBuf, process::Command
};
use clap::Parser;
@ -28,7 +28,10 @@ fn main() {
);
io::stdout().lock().flush().unwrap();
line.clear();
io::stdin().read_line(&mut line).unwrap();
if io::stdin().read_line(&mut line).unwrap() == 0 {
// EOF
return;
}
let line = line.trim();
if line.is_empty() {
continue;