Browse Source

fix: continue on empty line

main
fdai7381 2 years ago
parent
commit
6c3db77525
  1. 1
      src/error.rs
  2. 3
      src/execute.rs
  3. 3
      src/main.rs

1
src/error.rs

@ -1,3 +1,4 @@
pub enum ShellError {
EmptyLine,
Execute(String),
}

3
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);

3
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)
}

Loading…
Cancel
Save