Remove now unused out_events parameter

This commit is contained in:
Fabian Homborg 2021-10-26 17:32:13 +02:00
parent 0c3c3eaa99
commit 76f3564e2a
4 changed files with 12 additions and 28 deletions

View file

@ -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.

View file

@ -1322,8 +1322,7 @@ maybe_t<env_var_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<event_t> *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<event_t> *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<event_t> *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<event_t> *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();

View file

@ -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<event_t> *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<event_t> *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<event_t> *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<event_t> *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);

View file

@ -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));
}