mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-29 06:13:20 +00:00
Let parser::set_var_and_fire fire the event directly
The vector here gives us *nothing*
This commit is contained in:
parent
d9f094db1a
commit
da201ee8ac
3 changed files with 17 additions and 4 deletions
|
@ -517,6 +517,16 @@ event_t event_t::variable(wcstring name, wcstring_list_t args) {
|
|||
return evt;
|
||||
}
|
||||
|
||||
// static
|
||||
event_t event_t::variable_erase(wcstring name) {
|
||||
return event_t::variable(name, {L"VARIABLE", L"ERASE", name});
|
||||
}
|
||||
|
||||
// static
|
||||
event_t event_t::variable_set(wcstring name) {
|
||||
return event_t::variable(name, {L"VARIABLE", L"SET", name});
|
||||
}
|
||||
|
||||
// static
|
||||
event_t event_t::process_exit(pid_t pid, int status) {
|
||||
event_t evt{event_type_t::process_exit};
|
||||
|
|
|
@ -107,6 +107,10 @@ struct event_t {
|
|||
|
||||
/// Create an event_type_t::variable event.
|
||||
static event_t variable(wcstring name, wcstring_list_t args);
|
||||
/// Create an event_type_t::variable event with the args for erasing a variable.
|
||||
static event_t variable_erase(wcstring name);
|
||||
/// Create an event_type_t::variable event with the args for setting a variable.
|
||||
static event_t variable_set(wcstring name);
|
||||
|
||||
/// Create a PROCESS_EXIT event.
|
||||
static event_t process_exit(pid_t pid, int status);
|
||||
|
|
|
@ -102,10 +102,9 @@ parser_t &parser_t::principal_parser() {
|
|||
}
|
||||
|
||||
int parser_t::set_var_and_fire(const wcstring &key, env_mode_flags_t mode, wcstring_list_t vals) {
|
||||
std::vector<event_t> events;
|
||||
int res = vars().set(key, mode, std::move(vals), &events);
|
||||
for (const auto &evt : events) {
|
||||
event_fire(*this, evt);
|
||||
int res = vars().set(key, mode, std::move(vals), nullptr);
|
||||
if (res == ENV_OK) {
|
||||
event_fire(*this, event_t::variable_set(key));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue