diff options
author | Ian Fan <ianfan0@gmail.com> | 2018-08-07 11:46:11 +0100 |
---|---|---|
committer | Ian Fan <ianfan0@gmail.com> | 2018-08-18 15:50:26 +0100 |
commit | 7717c2231a614ba1a7e8ec1b22883e6fe1a228d5 (patch) | |
tree | 7e1e945be265b133c7993ab18003b8580f34771f | |
parent | c1af79532f7727110e75c3736899d998bc9840a5 (diff) | |
download | sway-7717c2231a614ba1a7e8ec1b22883e6fe1a228d5.tar.xz |
commands: require set variable to start with $
-rw-r--r-- | sway/commands/set.c | 12 | ||||
-rw-r--r-- | sway/sway.5.scd | 2 |
2 files changed, 2 insertions, 12 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) { } struct cmd_results *cmd_set(int argc, char **argv) { - char *tmp; struct cmd_results *error = NULL; if ((error = checkarg(argc, "set", EXPECTED_AT_LEAST, 2))) { return error; } if (argv[0][0] != '$') { - wlr_log(WLR_INFO, "Warning: variable '%s' doesn't start with $", argv[0]); - - size_t size = snprintf(NULL, 0, "$%s", argv[0]); - tmp = malloc(size + 1); - if (!tmp) { - return cmd_results_new(CMD_FAILURE, "set", "Not possible to create variable $'%s'", argv[0]); - } - snprintf(tmp, size+1, "$%s", argv[0]); - - argv[0] = tmp; + return cmd_results_new(CMD_INVALID, "set", "variable '%s' must start with $", argv[0]); } struct sway_variable *var = NULL; diff --git a/sway/sway.5.scd b/sway/sway.5.scd index 0378a3d5..34389e41 100644 --- a/sway/sway.5.scd +++ b/sway/sway.5.scd @@ -51,7 +51,7 @@ The following commands may only be used in the configuration file. *wordexp*(3) for details). The same include file can only be included once; subsequent attempts will be ignored. -*set* <name> <value> +*set* $<name> <value> Sets variable $_name_ to _value_. You can use the new variable in the arguments of future commands. |