File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
src/libutil/include/nix/util Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -33,15 +33,28 @@ auto concatStrings(Parts &&... parts)
3333 return concatStringsSep ({}, views);
3434}
3535
36+ /* *
37+ * Add quotes around a string.
38+ */
39+ inline std::string quoteString (std::string_view s, char quote = ' \' ' )
40+ {
41+ std::string result;
42+ result.reserve (s.size () + 2 );
43+ result += quote;
44+ result += s;
45+ result += quote;
46+ return result;
47+ }
48+
3649/* *
3750 * Add quotes around a collection of strings.
3851 */
3952template <class C >
40- Strings quoteStrings (const C & c)
53+ Strings quoteStrings (const C & c, char quote = ' \' ' )
4154{
4255 Strings res;
4356 for (auto & s : c)
44- res.push_back (" ' " + s + " ' " );
57+ res.push_back (quoteString (s, quote) );
4558 return res;
4659}
4760
You can’t perform that action at this time.
0 commit comments