aboutsummaryrefslogtreecommitdiffhomepage
path: root/env_universal_common.cpp
diff options
context:
space:
mode:
authorGravatar Kevin Ballard <kevin@sb.org>2014-10-01 12:33:30 -0700
committerGravatar Kevin Ballard <kevin@sb.org>2014-10-01 12:35:15 -0700
commit43e451d4d8dbc96c853d9297065322457ac9c345 (patch)
tree68ee1df33e3a5868083e4c72cc1d98c2f3c41405 /env_universal_common.cpp
parent1be5e68e994b72ff60aa6221420761fe0f7271a2 (diff)
Find fishd file even when $HOME is unset
env.cpp sets up $HOME based on the current user, if it's not inherited from the environment. fishd_get_config should be using the same calculated value of $HOME. To that end, move universal variable initialization to after $HOME is set up, and read the value from the fish environment instead of using getenv(). Fixes #1725.
Diffstat (limited to 'env_universal_common.cpp')
-rw-r--r--env_universal_common.cpp22
1 files changed, 3 insertions, 19 deletions
diff --git a/env_universal_common.cpp b/env_universal_common.cpp
index f84f18ec..c39cfdc1 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;