diff options
Diffstat (limited to 'sway/commands/output/background.c')
-rw-r--r-- | sway/commands/output/background.c | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/sway/commands/output/background.c b/sway/commands/output/background.c index 054fb707..68ee9fe1 100644 --- a/sway/commands/output/background.c +++ b/sway/commands/output/background.c | |||
@@ -4,7 +4,6 @@ | |||
4 | #include <string.h> | 4 | #include <string.h> |
5 | #include <strings.h> | 5 | #include <strings.h> |
6 | #include <unistd.h> | 6 | #include <unistd.h> |
7 | #include <wordexp.h> | ||
8 | #include <errno.h> | 7 | #include <errno.h> |
9 | #include "sway/commands.h" | 8 | #include "sway/commands.h" |
10 | #include "sway/config.h" | 9 | #include "sway/config.h" |
@@ -79,26 +78,15 @@ struct cmd_results *output_cmd_background(int argc, char **argv) { | |||
79 | return cmd_results_new(CMD_INVALID, "Missing background file"); | 78 | return cmd_results_new(CMD_INVALID, "Missing background file"); |
80 | } | 79 | } |
81 | 80 | ||
82 | wordexp_t p = {0}; | ||
83 | char *src = join_args(argv, j); | 81 | char *src = join_args(argv, j); |
84 | while (strstr(src, " ")) { | 82 | if (!expand_path(&src)) { |
85 | src = realloc(src, strlen(src) + 2); | ||
86 | char *ptr = strstr(src, " ") + 1; | ||
87 | memmove(ptr + 1, ptr, strlen(ptr) + 1); | ||
88 | *ptr = '\\'; | ||
89 | } | ||
90 | if (wordexp(src, &p, 0) != 0 || p.we_wordv[0] == NULL) { | ||
91 | struct cmd_results *cmd_res = cmd_results_new(CMD_INVALID, | 83 | struct cmd_results *cmd_res = cmd_results_new(CMD_INVALID, |
92 | "Invalid syntax (%s)", src); | 84 | "Invalid syntax (%s)", src); |
93 | free(src); | 85 | free(src); |
94 | wordfree(&p); | ||
95 | return cmd_res; | 86 | return cmd_res; |
96 | } | 87 | } |
97 | free(src); | ||
98 | src = join_args(p.we_wordv, p.we_wordc); | ||
99 | wordfree(&p); | ||
100 | if (!src) { | 88 | if (!src) { |
101 | sway_log(SWAY_ERROR, "Failed to duplicate string"); | 89 | sway_log(SWAY_ERROR, "Failed to allocate expanded path"); |
102 | return cmd_results_new(CMD_FAILURE, "Unable to allocate resource"); | 90 | return cmd_results_new(CMD_FAILURE, "Unable to allocate resource"); |
103 | } | 91 | } |
104 | 92 | ||