summaryrefslogtreecommitdiff
path: root/lib/utils/mu-utils.hh
diff options
context:
space:
mode:
authorDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2026-03-07 15:49:44 +0200
committerDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2026-04-17 23:41:21 +0300
commit83c4dc641dfc5bd07bbdbfe53c663f97533f17af (patch)
treeb0a77d0191d4d08c42c504f27efcd767f2a6d944 /lib/utils/mu-utils.hh
parentc38519da7bd43f9cfe359d6547a2a682bdb08b9a (diff)
mu/lib: fix some possible quoting issues
Diffstat (limited to 'lib/utils/mu-utils.hh')
-rw-r--r--lib/utils/mu-utils.hh18
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/utils/mu-utils.hh b/lib/utils/mu-utils.hh
index c465689..5758c31 100644
--- a/lib/utils/mu-utils.hh
+++ b/lib/utils/mu-utils.hh
@@ -497,7 +497,7 @@ to_string(const T& val)
*
* @return a string_view
*/
-static inline std::string_view
+inline std::string_view
to_string_view(const std::string& s)
{
return std::string_view{s.data(), s.size()};
@@ -510,7 +510,7 @@ to_string_view(const std::string& s)
*
* @return a std::string, empty if gchar was {}
*/
-static inline std::string
+inline std::string
to_string_gchar(gchar*&& str)
{
std::string s(str?str:"");
@@ -524,7 +524,7 @@ to_string_gchar(gchar*&& str)
*
* @return a std::string, empty if gchar was {}
*/
-static inline std::string
+inline std::string
to_string_char(char*&& str)
{
std::string s(str?str:"");
@@ -532,6 +532,18 @@ to_string_char(char*&& str)
return s;
}
+/**
+ * Shell-quote the given string (as per g_shell_quote())
+ *
+ * @param str some string
+ *
+ * @return quoted string
+ */
+inline std::string shell_quote(const std::string& str) {
+ return to_string_gchar(g_shell_quote(str.c_str()));
+}
+
+
/*
* Lexnums are lexicographically sortable string representations of non-negative
* integers. Start with 'f' + length of hex-representation number, followed by