diff --git a/env.cpp b/env.cpp index 749c1b1b7..167e0a362 100644 --- a/env.cpp +++ b/env.cpp @@ -530,11 +530,6 @@ void env_init(const struct config_paths_t *paths /* or NULL */) env_set(L"version", version.c_str(), ENV_GLOBAL); env_set(L"FISH_VERSION", version.c_str(), ENV_GLOBAL); - /* Set up universal variables. The empty string means to use the deafult path. */ - assert(s_universal_variables == NULL); - s_universal_variables = new env_universal_t(L""); - s_universal_variables->load(); - /* Set up SHLVL variable */ @@ -570,6 +565,11 @@ void env_init(const struct config_paths_t *paths /* or NULL */) /* Set PWD */ env_set_pwd(); + /* Set up universal variables. The empty string means to use the deafult path. */ + assert(s_universal_variables == NULL); + s_universal_variables = new env_universal_t(L""); + s_universal_variables->load(); + /* Set g_log_forks */ env_var_t log_forks = env_get_string(L"fish_log_forks"); g_log_forks = ! log_forks.missing_or_empty() && from_string(log_forks); diff --git a/env_universal_common.cpp b/env_universal_common.cpp index f84f18ec5..c39cfdc1e 100644 --- a/env_universal_common.cpp +++ b/env_universal_common.cpp @@ -547,28 +547,12 @@ bool env_universal_t::move_new_vars_file_into_place(const wcstring &src, const w return ret == 0; } -/** - Get environment variable value. - */ -static env_var_t fishd_env_get(const char *key) -{ - const char *env = getenv(key); - if (env != NULL) - { - return env_var_t(str2wcstring(env)); - } - else - { - return env_var_t::missing_var(); - } -} - static wcstring fishd_get_config() { bool done = false; wcstring result; - - env_var_t xdg_dir = fishd_env_get("XDG_CONFIG_HOME"); + + env_var_t xdg_dir = env_get_string(L"XDG_CONFIG_HOME", ENV_GLOBAL | ENV_EXPORT); if (! xdg_dir.missing_or_empty()) { result = xdg_dir; @@ -580,7 +564,7 @@ static wcstring fishd_get_config() } else { - env_var_t home = fishd_env_get("HOME"); + env_var_t home = env_get_string(L"HOME", ENV_GLOBAL | ENV_EXPORT); if (! home.missing_or_empty()) { result = home;