Rework exit command

Prior to this fix, the `exit` command would set a global variable in the
reader, which parse_execution would check. However in concurrent mode you
may have multiple scripts being sourced at once, and 'exit' should only
apply to the current script.

Switch to using a variable in the parser's libdata instead.
This commit is contained in:
ridiculousfish
2020-08-15 14:41:11 -07:00
parent a83dbec075
commit b0182183d4
6 changed files with 102 additions and 96 deletions

View File

@@ -182,11 +182,19 @@ struct library_data_t {
bool suppress_fish_trace{false};
/// Whether we should break or continue the current loop.
/// This is set by the 'break' and 'continue' commands.
enum loop_status_t loop_status { loop_status_t::normals };
/// Whether we should return from the current function.
/// This is set by the 'return' command.
bool returning{false};
/// Whether we should stop executing.
/// This is set by the 'exit' command, and unset after 'reader_read'.
/// Note this only exits up to the "current script boundary." That is, a call to exit within a
/// 'source' or 'read' command will only exit up to that command.
bool exit_current_script{false};
/// The read limit to apply to captured subshell output, or 0 for none.
size_t read_limit{0};