From 1cf737489db68312556d0a215c17e93a573b283f Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Thu, 13 Sep 2018 21:55:46 -0400 Subject: [PATCH] Escape spaces in background file path --- sway/commands/output/background.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sway/commands/output/background.c b/sway/commands/output/background.c index 8ab52a2e..2ff5f0d7 100644 --- a/sway/commands/output/background.c +++ b/sway/commands/output/background.c @@ -63,6 +63,12 @@ struct cmd_results *output_cmd_background(int argc, char **argv) { wordexp_t p; char *src = join_args(argv, j); + while (strstr(src, " ")) { + src = realloc(src, strlen(src) + 2); + char *ptr = strstr(src, " ") + 1; + memmove(ptr + 1, ptr, strlen(ptr) + 1); + *ptr = '\\'; + } if (wordexp(src, &p, 0) != 0 || p.we_wordv[0] == NULL) { struct cmd_results *cmd_res = cmd_results_new(CMD_INVALID, "output", "Invalid syntax (%s)", src);