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

@@ -2063,8 +2063,8 @@ void reader_import_history_if_necessary(void) {
// Try opening a bash file. We make an effort to respect $HISTFILE; this isn't very complete
// (AFAIK it doesn't have to be exported), and to really get this right we ought to ask bash
// itself. But this is better than nothing.
const env_var_t var = env_get_string(L"HISTFILE");
wcstring path = (var.missing() ? L"~/.bash_history" : var);
const env_var_t var = env_get(L"HISTFILE");
wcstring path = (var.missing() ? L"~/.bash_history" : var.as_string());
expand_tilde(path);
FILE *f = wfopen(path, "r");
if (f) {