commit bf2298e0a5265ede7a056f1247a4aab7e76f4b3d
parent f55b5a4982d9db45840f001e11118107536ed011
Author: Denis Doria <denisdoria@gmail.com>
Date: Fri, 3 Jun 2016 11:26:47 +0200
Includes $ for variables without it
Diffstat:
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/sway/commands.c b/sway/commands.c
@@ -2146,6 +2146,8 @@ static int compare_set_qsort(const void *_l, const void *_r) {
}
static struct cmd_results *cmd_set(int argc, char **argv) {
+ char *tmp;
+ int size;
struct cmd_results *error = NULL;
if (!config->reading) return cmd_results_new(CMD_FAILURE, "set", "Can only be used in config file.");
if ((error = checkarg(argc, "set", EXPECTED_AT_LEAST, 2))) {
@@ -2153,7 +2155,15 @@ static struct cmd_results *cmd_set(int argc, char **argv) {
}
if (argv[0][0] != '$') {
- return cmd_results_new(CMD_FAILURE, "set", "Malformed variable assignment, name has to start with $");
+ sway_log(L_INFO, "Warning: variable '%s' doesn't start with $", argv[0]);
+
+ size = asprintf(&tmp, "%s%s", "$", argv[0]);
+ if (size == -1) {
+ return cmd_results_new(CMD_FAILURE, "set", "Not possible to create variable $'%s'", argv[0]);
+ }
+
+ argv[0] = strdup(tmp);
+ free(tmp);
}
struct sway_variable *var = NULL;