diff --git a/src/builtin_set.cpp b/src/builtin_set.cpp index 34978f0d8..ffca47886 100644 --- a/src/builtin_set.cpp +++ b/src/builtin_set.cpp @@ -604,7 +604,7 @@ static int builtin_set_erase(const wchar_t *cmd, set_cmd_opts_t &opts, int argc, int retval = STATUS_CMD_OK; if (split->indexes.empty()) { // unset the var - retval = parser.vars().remove(split->varname, scope, nullptr); + retval = parser.vars().remove(split->varname, scope); // When a non-existent-variable is unset, return ENV_NOT_FOUND as $status // but do not emit any errors at the console as a compromise between user // friendliness and correctness. diff --git a/src/env.cpp b/src/env.cpp index c23ba1552..3282b8aa6 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -1322,8 +1322,7 @@ maybe_t env_stack_t::get(const wcstring &key, env_mode_flags_t mode) wcstring_list_t env_stack_t::get_names(int flags) const { return acquire_impl()->get_names(flags); } -int env_stack_t::set(const wcstring &key, env_mode_flags_t mode, wcstring_list_t vals, - std::vector *out_events) { +int env_stack_t::set(const wcstring &key, env_mode_flags_t mode, wcstring_list_t vals) { // Historical behavior. if (vals.size() == 1 && (key == L"PWD" || key == L"HOME")) { path_make_canonical(vals.front()); @@ -1345,9 +1344,6 @@ int env_stack_t::set(const wcstring &key, env_mode_flags_t mode, wcstring_list_t if (ret.global_modified || is_principal()) { env_dispatch_var_change(key, *this); } - if (out_events) { - out_events->push_back(event_t::variable(key, {L"VARIABLE", L"SET", key})); - } } // If the principal stack modified universal variables, then post a barrier. if (ret.uvar_modified && is_principal()) { @@ -1356,28 +1352,23 @@ int env_stack_t::set(const wcstring &key, env_mode_flags_t mode, wcstring_list_t return ret.status; } -int env_stack_t::set_one(const wcstring &key, env_mode_flags_t mode, wcstring val, - std::vector *out_events) { +int env_stack_t::set_one(const wcstring &key, env_mode_flags_t mode, wcstring val) { wcstring_list_t vals; vals.push_back(std::move(val)); - return set(key, mode, std::move(vals), out_events); + return set(key, mode, std::move(vals)); } -int env_stack_t::set_empty(const wcstring &key, env_mode_flags_t mode, - std::vector *out_events) { - return set(key, mode, {}, out_events); +int env_stack_t::set_empty(const wcstring &key, env_mode_flags_t mode) { + return set(key, mode, {}); } -int env_stack_t::remove(const wcstring &key, int mode, std::vector *out_events) { +int env_stack_t::remove(const wcstring &key, int mode) { mod_result_t ret = acquire_impl()->remove(key, mode); if (ret.status == ENV_OK) { if (ret.global_modified || is_principal()) { // Important to not hold the lock here. env_dispatch_var_change(key, *this); } - if (out_events) { - out_events->push_back(event_t::variable(key, {L"VARIABLE", L"ERASE", key})); - } } if (ret.uvar_modified && is_principal()) { universal_barrier(); diff --git a/src/env.h b/src/env.h index 208dda14a..595409e9a 100644 --- a/src/env.h +++ b/src/env.h @@ -231,18 +231,13 @@ class env_stack_t final : public environment_t { wcstring_list_t get_names(int flags) const override; /// Sets the variable with the specified name to the given values. - /// If \p out_events is supplied, populate it with any events generated through setting the - /// variable. - int set(const wcstring &key, env_mode_flags_t mode, wcstring_list_t vals, - std::vector *out_events = nullptr); + int set(const wcstring &key, env_mode_flags_t mode, wcstring_list_t vals); /// Sets the variable with the specified name to a single value. - int set_one(const wcstring &key, env_mode_flags_t mode, wcstring val, - std::vector *out_events = nullptr); + int set_one(const wcstring &key, env_mode_flags_t mode, wcstring val); /// Sets the variable with the specified name to no values. - int set_empty(const wcstring &key, env_mode_flags_t mode, - std::vector *out_events = nullptr); + int set_empty(const wcstring &key, env_mode_flags_t mode); /// Update the PWD variable based on the result of getcwd. void set_pwd_from_getcwd(); @@ -253,11 +248,9 @@ class env_stack_t final : public environment_t { /// \param mode should be ENV_USER if this is a remove request from the user, 0 otherwise. If /// this is a user request, read-only variables can not be removed. The mode may also specify /// the scope of the variable that should be erased. - /// \param out_events if non-null, populate it with any events generated from removing this - /// variable. /// /// \return zero if the variable existed, and non-zero if the variable did not exist - int remove(const wcstring &key, int mode, std::vector *out_events = nullptr); + int remove(const wcstring &key, int mode); /// Push the variable stack. Used for implementing local variables for functions and for-loops. void push(bool new_scope); diff --git a/src/parser.cpp b/src/parser.cpp index 91373eaca..d44bdab18 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -102,7 +102,7 @@ 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) { - int res = vars().set(key, mode, std::move(vals), nullptr); + int res = vars().set(key, mode, std::move(vals)); if (res == ENV_OK) { event_fire(*this, event_t::variable_set(key)); }