summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRory Dudley2024-02-16 22:35:43 -0700
committerRory Dudley2024-02-16 22:35:43 -0700
commitf7b6c2dae63a1ada4fd097b5714d93494003ea98 (patch)
tree306293f513891915e75fcb56873ca977a016069a
parent508550c4d5c1b8933decfb47fc02481959ab0c65 (diff)
downloaddwarvish-f7b6c2dae63a1ada4fd097b5714d93494003ea98.tar.gz
Detect EOF
Added logic to detect for an EOF (i.e. <C-d>).
-rw-r--r--src/main.rs9
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