diff --git a/src/error.rs b/src/error.rs index 291a017..49740d9 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,3 +1,4 @@ pub enum ShellError { + EmptyLine, Execute(String), } diff --git a/src/execute.rs b/src/execute.rs index bfce3d2..362d217 100644 --- a/src/execute.rs +++ b/src/execute.rs @@ -5,6 +5,9 @@ use crate::error::ShellError::Execute; use crate::parse::parse_line; pub fn interpret(line: &str) -> Result<(), ShellError> { + if line.is_empty() { + return Err(ShellError::EmptyLine); + } let (keyword, args) = parse_line(line); let mut command = Command::new(keyword); diff --git a/src/main.rs b/src/main.rs index a8ebe92..75728d3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,6 +21,9 @@ fn main() -> Result<()> { match readline { Ok(line) => match interpret(&line) { Ok(_) => {} + Err(ShellError::EmptyLine) => { + continue; + } Err(ShellError::Execute(err)) => { eprintln!("{}", err) }