diff options
author | 2018-08-07 11:46:11 +0100 | |
---|---|---|
committer | 2018-08-18 15:50:26 +0100 | |
commit | 7717c2231a614ba1a7e8ec1b22883e6fe1a228d5 (patch) | |
tree | 7e1e945be265b133c7993ab18003b8580f34771f /sway/commands/set.c | |
parent | commands: add nop (diff) | |
download | sway-7717c2231a614ba1a7e8ec1b22883e6fe1a228d5.tar.gz sway-7717c2231a614ba1a7e8ec1b22883e6fe1a228d5.tar.zst sway-7717c2231a614ba1a7e8ec1b22883e6fe1a228d5.zip |
commands: require set variable to start with $
Diffstat (limited to 'sway/commands/set.c')
-rw-r--r-- | sway/commands/set.c | 12 |
1 files changed, 1 insertions, 11 deletions
diff --git a/sway/commands/set.c b/sway/commands/set.c index ea388d3b..be51230b 100644 --- a/sway/commands/set.c +++ b/sway/commands/set.c | |||
@@ -25,23 +25,13 @@ void free_sway_variable(struct sway_variable *var) { | |||
25 | } | 25 | } |
26 | 26 | ||
27 | struct cmd_results *cmd_set(int argc, char **argv) { | 27 | struct cmd_results *cmd_set(int argc, char **argv) { |
28 | char *tmp; | ||
29 | struct cmd_results *error = NULL; | 28 | struct cmd_results *error = NULL; |
30 | if ((error = checkarg(argc, "set", EXPECTED_AT_LEAST, 2))) { | 29 | if ((error = checkarg(argc, "set", EXPECTED_AT_LEAST, 2))) { |
31 | return error; | 30 | return error; |
32 | } | 31 | } |
33 | 32 | ||
34 | if (argv[0][0] != '$') { | 33 | if (argv[0][0] != '$') { |
35 | wlr_log(WLR_INFO, "Warning: variable '%s' doesn't start with $", argv[0]); | 34 | return cmd_results_new(CMD_INVALID, "set", "variable '%s' must start with $", argv[0]); |
36 | |||
37 | size_t size = snprintf(NULL, 0, "$%s", argv[0]); | ||
38 | tmp = malloc(size + 1); | ||
39 | if (!tmp) { | ||
40 | return cmd_results_new(CMD_FAILURE, "set", "Not possible to create variable $'%s'", argv[0]); | ||
41 | } | ||
42 | snprintf(tmp, size+1, "$%s", argv[0]); | ||
43 | |||
44 | argv[0] = tmp; | ||
45 | } | 35 | } |
46 | 36 | ||
47 | struct sway_variable *var = NULL; | 37 | struct sway_variable *var = NULL; |