Stop exporting empty variables as ENV_NULL

Localize the encoding of empty variables as ENV_NULL into the universal
variables component, and ensure they are not exported as ENV_NULL.

Fixes #4846
This commit is contained in:
ridiculousfish
2018-03-24 23:32:55 -07:00
parent 517b77ca74
commit 669eafb55f
8 changed files with 71 additions and 58 deletions

View File

@@ -1791,6 +1791,33 @@ bool contains(const wcstring_list_t &list, const wcstring &str) {
return std::find(list.begin(), list.end(), str) != list.end();
}
wcstring_list_t split_string(const wcstring &val, wchar_t sep) {
wcstring_list_t out;
size_t pos = 0, end = val.size();
while (pos <= end) {
size_t next_pos = val.find(sep, pos);
if (next_pos == wcstring::npos) {
next_pos = end;
}
out.emplace_back(val, pos, next_pos - pos);
pos = next_pos + 1; // skip the separator, or skip past the end
}
return out;
}
wcstring join_strings(const wcstring_list_t &vals, wchar_t sep) {
wcstring result;
bool first = true;
for (const wcstring &s : vals) {
if (!first) {
result.push_back(sep);
}
result.append(s);
first = false;
}
return result;
}
int create_directory(const wcstring &d) {
bool ok = false;
struct stat buf;