mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-24 17:41:16 -03:00
Join variables by their delimiter in quoted expansion
This switches quoted expansion like "$foo" to use foo's delimiter instead of space. The delimiter is space for normal variables and colonf or path variables. Expansions like "$PATH" will now expand using ':'.
This commit is contained in:
@@ -1898,7 +1898,18 @@ wcstring_list_t split_string(const wcstring &val, wchar_t sep) {
|
||||
}
|
||||
|
||||
wcstring join_strings(const wcstring_list_t &vals, wchar_t sep) {
|
||||
if (vals.empty()) return wcstring{};
|
||||
|
||||
// Reserve the size we will need.
|
||||
// count-1 separators, plus the length of all strings.
|
||||
size_t size = vals.size() - 1;
|
||||
for (const wcstring &s : vals) {
|
||||
size += s.size();
|
||||
}
|
||||
|
||||
// Construct the string.
|
||||
wcstring result;
|
||||
result.reserve(size);
|
||||
bool first = true;
|
||||
for (const wcstring &s : vals) {
|
||||
if (!first) {
|
||||
|
||||
Reference in New Issue
Block a user