Remove another unnecessary env_var_t creation

This commit is contained in:
ridiculousfish 2018-09-30 18:30:13 -04:00
parent bd7fea55c4
commit e6d09dc4fe

View file

@ -970,13 +970,14 @@ static expand_error_t expand_stage_wildcards(const wcstring &input, std::vector<
} else {
// Get the PATH/CDPATH and CWD. Perhaps these should be passed in. An empty CDPATH
// implies just the current directory, while an empty PATH is left empty.
const wchar_t *name = for_cd ? L"CDPATH" : L"PATH";
auto paths = env_get(name);
if (paths.missing_or_empty()) {
paths = env_var_t(name, for_cd ? L"." : L"");
wcstring_list_t paths;
if (auto paths_var = env_get(for_cd ? L"CDPATH" : L"PATH")) {
paths = paths_var->as_list();
}
for (const wcstring &next_path : paths->as_list()) {
if (paths.empty()) {
paths.emplace_back(for_cd ? L"." : L"");
}
for (const wcstring &next_path : paths) {
effective_working_dirs.push_back(
path_apply_working_directory(next_path, working_dir));
}