Skip to content

Commit

Permalink
repl/single: Fold exit points
Browse files Browse the repository at this point in the history
  • Loading branch information
lhmouse committed Mar 3, 2025
1 parent 32264c8 commit 01f7d86
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions repl/single.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@ load_and_execute_single_noreturn()

// Execute the script, passing all command-line arguments to it. If the
// script exits without returning a value, success is assumed.
Exit_Status status = exit_non_integer;
auto ref = repl_script.execute(move(repl_args));
if(ref.is_void())
quick_exit();

const auto& val = ref.dereference_readonly();
if(val.is_integer())
quick_exit(static_cast<Exit_Status>(val.as_integer()));
status = exit_success;
else {
const auto& val = ref.dereference_readonly();
if(val.is_integer())
status = static_cast<Exit_Status>(val.as_integer());
}

quick_exit(exit_non_integer);
quick_exit(status);
}

} // namespace asteria

0 comments on commit 01f7d86

Please sign in to comment.