mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
parent
529ba30b1a
commit
3b92d99277
1 changed files with 25 additions and 19 deletions
|
@ -867,6 +867,7 @@ void env_init(const struct config_paths_t *paths /* or NULL */) {
|
||||||
// env HOME=(mktemp -d) su --preserve-environment fish
|
// env HOME=(mktemp -d) su --preserve-environment fish
|
||||||
if (env_get_string(L"HOME").missing_or_empty()) {
|
if (env_get_string(L"HOME").missing_or_empty()) {
|
||||||
const env_var_t unam = env_get_string(L"USER");
|
const env_var_t unam = env_get_string(L"USER");
|
||||||
|
if (!unam.missing_or_empty()) {
|
||||||
char *unam_narrow = wcs2str(unam.c_str());
|
char *unam_narrow = wcs2str(unam.c_str());
|
||||||
struct passwd userinfo;
|
struct passwd userinfo;
|
||||||
struct passwd *result;
|
struct passwd *result;
|
||||||
|
@ -889,6 +890,11 @@ void env_init(const struct config_paths_t *paths /* or NULL */) {
|
||||||
env_set(L"HOME", ENV_NULL, ENV_GLOBAL | ENV_EXPORT);
|
env_set(L"HOME", ENV_NULL, ENV_GLOBAL | ENV_EXPORT);
|
||||||
}
|
}
|
||||||
free(unam_narrow);
|
free(unam_narrow);
|
||||||
|
} else {
|
||||||
|
// If $USER is empty as well (which we tried to set above),
|
||||||
|
// we can't get $HOME.
|
||||||
|
env_set(L"HOME", ENV_NULL, ENV_GLOBAL | ENV_EXPORT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
env_set_pwd(); // initialize the PWD variable
|
env_set_pwd(); // initialize the PWD variable
|
||||||
|
|
Loading…
Reference in a new issue