From 32ae26e519eeb6a5108f1d82fe36ce5b6ef65af3 Mon Sep 17 00:00:00 2001 From: Mikkel Oscar Lyderik Date: Mon, 25 Jan 2016 00:02:28 +0100 Subject: Add quotes to multiword arguments. This adds quotes around multiword arguments before they are passed to `/bin/sh -c` in an exec command. Example: I connect to irc like this: exec termite -e "mosh server tmux a" Without this patch the arguments are passed to sh as: termite -e mosh server tmux a When it should be: termite -e "mosh server tmux a" For the command to work. --- include/stringop.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/stringop.h b/include/stringop.h index bb681bcd..7c29a745 100644 --- a/include/stringop.h +++ b/include/stringop.h @@ -31,6 +31,11 @@ int unescape_string(char *string); char *join_args(char **argv, int argc); char *join_list(list_t *list, char *separator); +/** + * Add quotes around any argv with whitespaces. + */ +void add_quotes(char **argv, int argc); + // split string into 2 by delim. char *cmdsep(char **stringp, const char *delim); // Split string into 2 by delim, handle quotes -- cgit v1.2.3-54-g00ecf