mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-28 01:11:15 -03:00
Port env_init to Rust
- This does not adopt it.
This commit is contained in:
committed by
Fabian Boehm
parent
e7f8fb04cc
commit
96e58dac21
19
src/env.cpp
19
src/env.cpp
@@ -233,6 +233,25 @@ static std::map<wcstring, wcstring> inheriteds;
|
||||
|
||||
const std::map<wcstring, wcstring> &env_get_inherited() { return inheriteds; }
|
||||
|
||||
void set_inheriteds_ffi() {
|
||||
wcstring key, val;
|
||||
const char *const *envp = environ;
|
||||
int i = 0;
|
||||
while (envp && envp[i]) i++;
|
||||
while (i--) {
|
||||
const wcstring key_and_val = str2wcstring(envp[i]);
|
||||
size_t eql = key_and_val.find(L'=');
|
||||
if (eql == wcstring::npos) {
|
||||
// PORTING: Should this not be key_and_val?
|
||||
inheriteds[key] = L"";
|
||||
} else {
|
||||
key.assign(key_and_val, 0, eql);
|
||||
val.assign(key_and_val, eql + 1, wcstring::npos);
|
||||
inheriteds[key] = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void env_init(const struct config_paths_t *paths, bool do_uvars, bool default_paths) {
|
||||
env_stack_t &vars = env_stack_t::principal();
|
||||
// Import environment variables. Walk backwards so that the first one out of any duplicates wins
|
||||
|
||||
@@ -350,4 +350,6 @@ const std::map<wcstring, wcstring> &env_get_inherited();
|
||||
/// fish_history_val is the value of the "$fish_history" variable, or "fish" if not set.
|
||||
wcstring_list_ffi_t get_history_variable_text_ffi(const wcstring &fish_history_val);
|
||||
|
||||
void set_inheriteds_ffi();
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user