summaryrefslogtreecommitdiffstats
path: root/src/bfstd.h
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2023-06-16 13:44:06 -0400
committerTavian Barnes <tavianator@tavianator.com>2023-06-16 13:44:06 -0400
commitd3f4340a460a023656151f220f5923ec8ccf9894 (patch)
treec004b4b319bf164a25cd72f6c6f5b7f19b927368 /src/bfstd.h
parenta5550d478234efbb89d1c23ae3234bed626a47f6 (diff)
downloadbfs-d3f4340a460a023656151f220f5923ec8ccf9894.tar.xz
bfstd: New wordesc() function to shell-escape strings
Diffstat (limited to 'src/bfstd.h')
-rw-r--r--src/bfstd.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/bfstd.h b/src/bfstd.h
index ee4cf16..750847e 100644
--- a/src/bfstd.h
+++ b/src/bfstd.h
@@ -277,4 +277,17 @@ int xstrtofflags(const char **str, unsigned long long *set, unsigned long long *
*/
size_t xstrwidth(const char *str);
+// #include <wordexp.h>
+
+/**
+ * Escape a string as a single shell word.
+ *
+ * @param str
+ * The string to escape.
+ * @return
+ * A string that a shell would evaluate to str, dynamically allocated,
+ * or NULL on failure.
+ */
+char *wordesc(const char *str);
+
#endif // BFS_BFSTD_H