Eliminate wopen()

It was large and mostly unnecessary. Prefer wopen() followed by
fdopen().
This commit is contained in:
ridiculousfish
2020-01-28 10:43:37 -08:00
parent af2265b4b0
commit fc4557c784
5 changed files with 13 additions and 49 deletions

View File

@@ -2174,8 +2174,9 @@ void reader_import_history_if_necessary() {
const auto var = data->vars().get(L"HISTFILE");
wcstring path = (var ? var->as_string() : L"~/.bash_history");
expand_tilde(path, data->vars());
FILE *f = wfopen(path, "r");
if (f) {
int fd = wopen_cloexec(path, O_RDONLY);
if (fd >= 0) {
FILE *f = fdopen(fd, "r");
data->history->populate_from_bash(f);
fclose(f);
}