Skip to content

Commit

Permalink
Fix exit on syntax error
Browse files Browse the repository at this point in the history
  • Loading branch information
prsabahrami committed Sep 6, 2024
1 parent 0a38e5d commit d92035d
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions crates/shell/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,24 @@ fn commands() -> HashMap<String, Rc<dyn ShellCommand>> {
}

async fn execute(text: &str, state: &mut ShellState) -> anyhow::Result<i32> {
let list = deno_task_shell::parser::parse(text)?;
let list = deno_task_shell::parser::parse(text);

let mut stderr = ShellPipeWriter::stderr();
let stdout = ShellPipeWriter::stdout();
let stdin = ShellPipeReader::stdin();

if let Err(e) = list {
let _ = stderr.write_line(&format!("Syntax error: {}", e));
return Ok(1);
}

// spawn a sequential list and pipe its output to the environment
let result = execute_sequential_list(
list,
list.unwrap(),
state.clone(),
ShellPipeReader::stdin(),
ShellPipeWriter::stdout(),
ShellPipeWriter::stderr(),
stdin,
stdout,
stderr,
AsyncCommandBehavior::Wait,
)
.await;
Expand Down

0 comments on commit d92035d

Please sign in to comment.