Skip to content

Commit

Permalink
fix(chisel): panic on empty input (foundry-rs#4131)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes authored Jan 19, 2023
1 parent 5cdba88 commit d8f2434
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions chisel/src/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ impl ChiselDispatcher {
// Check if the input is a builtin command.
// Commands are denoted with a `!` leading character.
if input.starts_with(COMMAND_LEADER) {
let split: Vec<&str> = input.split(' ').collect();
let split: Vec<&str> = input.split_whitespace().collect();
let raw_cmd = &split[0][1..];

return match raw_cmd.parse::<ChiselCommand>() {
Expand All @@ -773,8 +773,8 @@ impl ChiselDispatcher {
DispatchResult::UnrecognizedCommand(e)
}
}
} else if input.is_empty() {
return DispatchResult::CommandFailed(Self::make_error("Input is empty."))
} else if input.trim().is_empty() {
return DispatchResult::CommandSuccess(None)
}

// Get a mutable reference to the session source
Expand Down

0 comments on commit d8f2434

Please sign in to comment.