diff options
author | Rory Dudley | 2024-02-16 22:35:43 -0700 |
---|---|---|
committer | Rory Dudley | 2024-02-16 22:35:43 -0700 |
commit | f7b6c2dae63a1ada4fd097b5714d93494003ea98 (patch) | |
tree | 306293f513891915e75fcb56873ca977a016069a | |
parent | 508550c4d5c1b8933decfb47fc02481959ab0c65 (diff) | |
download | dwarvish-f7b6c2dae63a1ada4fd097b5714d93494003ea98.tar.gz |
Detect EOF
Added logic to detect for an EOF (i.e. <C-d>).
-rw-r--r-- | src/main.rs | 9 |
1 files changed, 8 insertions, 1 deletions
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. <C-d>) + if bytes == 0 { + break; + } + + // Trim the input let input = input.trim(); // Check if user wants to exit the shell |