mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-28 17:51:15 -03:00
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:
@@ -95,6 +95,7 @@ static const std::vector<electric_var_t> electric_variables{
|
||||
{L"hostname", electric_var_t::freadonly},
|
||||
{L"pipestatus", electric_var_t::freadonly | electric_var_t::fcomputed},
|
||||
{L"status", electric_var_t::freadonly | electric_var_t::fcomputed},
|
||||
{L"status_generation", electric_var_t::freadonly | electric_var_t::fcomputed},
|
||||
{L"umask", electric_var_t::fcomputed},
|
||||
{L"version", electric_var_t::freadonly},
|
||||
};
|
||||
@@ -701,6 +702,9 @@ maybe_t<env_var_t> env_scoped_impl_t::try_get_computed(const wcstring &key) cons
|
||||
} else if (key == L"status") {
|
||||
const auto &js = perproc_data().statuses;
|
||||
return env_var_t(L"status", to_string(js.status));
|
||||
} else if (key == L"status_generation") {
|
||||
auto status_generation = reader_status_count();
|
||||
return env_var_t(L"status_generation", to_string(status_generation));
|
||||
} else if (key == L"fish_kill_signal") {
|
||||
const auto &js = perproc_data().statuses;
|
||||
return env_var_t(L"fish_kill_signal", to_string(js.kill_signal));
|
||||
|
||||
Reference in New Issue
Block a user