diff --git a/src/builtin_set.cpp b/src/builtin_set.cpp index 6ab298a0b..4e5f253e8 100644 --- a/src/builtin_set.cpp +++ b/src/builtin_set.cpp @@ -652,7 +652,7 @@ static int builtin_set_erase(const wchar_t *cmd, set_cmd_opts_t &opts, int argc, } if (idx_count == 0) { // unset the var - retval = env_remove(dest, scope); + retval = parser.vars().remove(dest, scope); // Temporarily swallowing ENV_NOT_FOUND errors to prevent // breaking all tests that unset variables that aren't set. if (retval != ENV_NOT_FOUND) { diff --git a/src/env.cpp b/src/env.cpp index c147e22d7..6258c845a 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -1435,8 +1435,6 @@ int env_set_empty(const wcstring &key, env_mode_flags_t mode) { return env_stack_t::principal().set_empty(key, mode); } -int env_remove(const wcstring &key, int mode) { return env_stack_t::principal().remove(key, mode); } - void env_universal_barrier() { env_stack_t::principal().universal_barrier(); } wcstring env_get_pwd_slash() { return env_stack_t::principal().get_pwd_slash(); } diff --git a/src/env.h b/src/env.h index 83e6434e4..a10880d3b 100644 --- a/src/env.h +++ b/src/env.h @@ -155,16 +155,6 @@ int env_set_one(const wcstring &key, env_mode_flags_t mode, wcstring val); /// Sets the variable with the specified name to no values. int env_set_empty(const wcstring &key, env_mode_flags_t mode); -/// Remove environment variable. -/// -/// \param key The name of the variable to remove -/// \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. -/// -/// \return zero if the variable existed, and non-zero if the variable did not exist -int env_remove(const wcstring &key, int mode); - /// Synchronizes all universal variable changes: writes everything out, reads stuff in. void env_universal_barrier(); diff --git a/src/fish_tests.cpp b/src/fish_tests.cpp index 6b6c8b6eb..6d241e22c 100644 --- a/src/fish_tests.cpp +++ b/src/fish_tests.cpp @@ -2762,7 +2762,7 @@ static void test_autosuggest_suggest_special() { perform_one_completion_cd_test(L"cd ~haha", L"ha/", __LINE__); perform_one_completion_cd_test(L"cd ~hahaha/", L"path1/", __LINE__); - env_remove(L"HOME", ENV_LOCAL | ENV_EXPORT); + parser_t::principal_parser().vars().remove(L"HOME", ENV_LOCAL | ENV_EXPORT); popd(); } @@ -4284,9 +4284,10 @@ static void test_highlighting() { {L"self%not", highlight_spec_param}, }); + auto &vars = parser_t::principal_parser().vars(); // Verify variables and wildcards in commands using /bin/cat. - env_set(L"VARIABLE_IN_COMMAND", ENV_LOCAL, {L"a"}); - env_set(L"VARIABLE_IN_COMMAND2", ENV_LOCAL, {L"at"}); + vars.set(L"VARIABLE_IN_COMMAND", ENV_LOCAL, {L"a"}); + vars.set(L"VARIABLE_IN_COMMAND2", ENV_LOCAL, {L"at"}); highlight_tests.push_back( {{L"/bin/ca", highlight_spec_command, ns}, {L"*", highlight_spec_operator, ns}}); @@ -4319,7 +4320,7 @@ static void test_highlighting() { do_test(expected_colors.size() == text.size()); std::vector colors(text.size()); - highlight_shell(text, colors, 20, NULL, env_vars_snapshot_t::current()); + highlight_shell(text, colors, 20, NULL, vars); if (expected_colors.size() != colors.size()) { err(L"Color vector has wrong size! Expected %lu, actual %lu", expected_colors.size(), @@ -4338,8 +4339,8 @@ static void test_highlighting() { } } } - env_remove(L"VARIABLE_IN_COMMAND", ENV_DEFAULT); - env_remove(L"VARIABLE_IN_COMMAND2", ENV_DEFAULT); + vars.remove(L"VARIABLE_IN_COMMAND", ENV_DEFAULT); + vars.remove(L"VARIABLE_IN_COMMAND2", ENV_DEFAULT); } static void test_wcstring_tok() {