summaryrefslogtreecommitdiff
path: root/src/utils.c
diff options
context:
space:
mode:
authorSven Willner <sven.willner@gmail.com>2018-09-13 15:47:18 +0200
committerSven Willner <sven.willner@gmail.com>2018-09-13 15:47:18 +0200
commit4ca5b177bbaf656611dd253d7c8e37317b5b186f (patch)
tree5f66934df56dfcbe11364bda57899d078511c3c8 /src/utils.c
parent3671b53046afbeced26162fc413fcfb7971116b9 (diff)
parent9241e8faa78cc02c08537ed0bd7b236d172c3ed7 (diff)
Merge branch 'master' of github.com:derf/feh
Diffstat (limited to 'src/utils.c')
-rw-r--r--src/utils.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/utils.c b/src/utils.c
index 4c06a48..ec30d4a 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -157,7 +157,7 @@ char *feh_unique_filename(char *path, char *basename)
{
char *tmpname;
char num[10];
- char cppid[10];
+ char cppid[12];
static long int i = 1;
struct stat st;
pid_t ppid;
@@ -201,3 +201,26 @@ char *ereadfile(char *path)
return estrdup(buffer);
}
+
+char *shell_escape(char *input)
+{
+ static char ret[1024];
+ unsigned int out = 0, in = 0;
+
+ ret[out++] = '\'';
+ for (in = 0; input[in] && (out < (sizeof(ret) - 7)); in++) {
+ if (input[in] == '\'') {
+ ret[out++] = '\'';
+ ret[out++] = '"';
+ ret[out++] = '\'';
+ ret[out++] = '"';
+ ret[out++] = '\'';
+ }
+ else
+ ret[out++] = input[in];
+ }
+ ret[out++] = '\'';
+ ret[out++] = '\0';
+
+ return ret;
+}