stop subclassing env_var_t from wcstring

This is the first step to implementing issue #4200 is to stop subclassing
env_var_t from wcstring. Not too surprisingly doing this identified
several places that were incorrectly treating env_var_t and wcstring as
interchangeable types. I'm not talking about those places that passed
an env_var_t instance to a function that takes a wcstring. I'm talking
about doing things like assigning the former to the latter type, relying
on the implicit conversion, and thus losing information.

We also rename `env_get_string()` to `env_get()` for symmetry with
`env_set()` and to make it clear the function does not return a string.
This commit is contained in:
Kurtis Rader
2017-08-05 18:22:49 -07:00
parent d87c0424d8
commit c36ad27618
22 changed files with 205 additions and 186 deletions

View File

@@ -405,7 +405,7 @@ void exec_job(parser_t &parser, job_t *j) {
// really make sense, so I'm not trying to fix it here.
if (!setup_child_process(j, 0, all_ios)) {
// Decrement SHLVL as we're removing ourselves from the shell "stack".
const env_var_t shlvl_str = env_get_string(L"SHLVL", ENV_GLOBAL | ENV_EXPORT);
const env_var_t shlvl_str = env_get(L"SHLVL", ENV_GLOBAL | ENV_EXPORT);
wcstring nshlvl_str = L"0";
if (!shlvl_str.missing()) {
long shlvl_i = fish_wcstol(shlvl_str.c_str());
@@ -1111,7 +1111,7 @@ static int exec_subshell_internal(const wcstring &cmd, wcstring_list_t *lst, boo
const int prev_status = proc_get_last_status();
bool split_output = false;
const env_var_t ifs = env_get_string(L"IFS");
const env_var_t ifs = env_get(L"IFS");
if (!ifs.missing_or_empty()) {
split_output = true;
}