From f7b6c2dae63a1ada4fd097b5714d93494003ea98 Mon Sep 17 00:00:00 2001 From: Rory Dudley Date: Fri, 16 Feb 2024 22:35:43 -0700 Subject: Detect EOF Added logic to detect for an EOF (i.e. ). --- src/main.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index c592e51..42fa2a9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,9 +21,16 @@ fn eval(paths: &[&str], prompt: &str) { // Wait for user input let mut input = String::new(); - io::stdin() + let bytes = io::stdin() .read_line(&mut input) .expect("Unable to evaluate the input string"); + + // Check if we've reached EOF (i.e. ) + if bytes == 0 { + break; + } + + // Trim the input let input = input.trim(); // Check if user wants to exit the shell -- cgit v1.2.3