Add a $status_generation variable that's incremented for each interactive command that produces a status.

This can be used to determine whether the previous command produced a real status, or just carried over the status from the command before it. Backgrounded commands and variable assignments will not increment status_generation, all other commands will.
This commit is contained in:
Soumya
2020-08-02 13:37:19 -07:00
committed by ridiculousfish
parent 54823c9243
commit a2b2bcef6e
10 changed files with 140 additions and 7 deletions

View File

@@ -142,6 +142,9 @@ struct library_data_t {
/// A counter incremented every time a command executes.
uint64_t exec_count{0};
/// A counter incremented every time a command produces a $status.
uint64_t status_count{0};
/// Last reader run count.
uint64_t last_exec_run_counter{UINT64_MAX};
@@ -219,9 +222,12 @@ struct eval_res_t {
/// If set, no commands were executed and there we no errors.
bool was_empty{false};
/// If set, no commands produced a $status value.
bool no_status{false};
/* implicit */ eval_res_t(proc_status_t status, bool break_expand = false,
bool was_empty = false)
: status(status), break_expand(break_expand), was_empty(was_empty) {}
bool was_empty = false, bool no_status = false)
: status(status), break_expand(break_expand), was_empty(was_empty), no_status(no_status) {}
};
class parser_t : public std::enable_shared_from_this<parser_t> {