From 1ab3e1023e026cf9d6c51497739401fe580bf304 Mon Sep 17 00:00:00 2001 From: thuck Date: Thu, 2 Jun 2016 23:23:04 +0200 Subject: Including error message when variable do not start with $ --- sway/commands.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sway/commands.c b/sway/commands.c index 3befee13..3ccbcd2e 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -2152,6 +2152,10 @@ static struct cmd_results *cmd_set(int argc, char **argv) { return error; } + if (argv[0][0] != '$') { + return cmd_results_new(CMD_FAILURE, "set", "Malformed variable assignment, name has to start with $"); + } + struct sway_variable *var = NULL; // Find old variable if it exists int i; -- cgit v1.2.3-54-g00ecf From e4f80877bea48eb29b4ddfbce923bf78a6694ffb Mon Sep 17 00:00:00 2001 From: thuck Date: Fri, 3 Jun 2016 00:05:10 +0200 Subject: Fix output command when varible not set This should fix the corner case where a variable is not assigned, but used anyway. This should solve partially the issue #681. --- sway/commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sway/commands.c b/sway/commands.c index 3ccbcd2e..febff2dd 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -1632,7 +1632,7 @@ static struct cmd_results *cmd_output(int argc, char **argv) { } char *src = join_args(argv + i, argc - i - 1); char *mode = argv[argc - 1]; - if (wordexp(src, &p, 0) != 0) { + if (wordexp(src, &p, 0) != 0 || p.we_wordv[0] == NULL) { return cmd_results_new(CMD_INVALID, "output", "Invalid syntax (%s)", src); } free(src); -- cgit v1.2.3-54-g00ecf From f55b5a4982d9db45840f001e11118107536ed011 Mon Sep 17 00:00:00 2001 From: thuck Date: Fri, 3 Jun 2016 00:36:41 +0200 Subject: Fix identation issue --- sway/commands.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sway/commands.c b/sway/commands.c index febff2dd..41233591 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -2152,9 +2152,9 @@ static struct cmd_results *cmd_set(int argc, char **argv) { return error; } - if (argv[0][0] != '$') { - return cmd_results_new(CMD_FAILURE, "set", "Malformed variable assignment, name has to start with $"); - } + if (argv[0][0] != '$') { + return cmd_results_new(CMD_FAILURE, "set", "Malformed variable assignment, name has to start with $"); + } struct sway_variable *var = NULL; // Find old variable if it exists -- cgit v1.2.3-54-g00ecf From bf2298e0a5265ede7a056f1247a4aab7e76f4b3d Mon Sep 17 00:00:00 2001 From: Denis Doria Date: Fri, 3 Jun 2016 11:26:47 +0200 Subject: Includes $ for variables without it --- sway/commands.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sway/commands.c b/sway/commands.c index 41233591..e204fb40 100644 --- 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; -- cgit v1.2.3-54-g00ecf From 29eb3bf7467d721d89cf4a7925d2e41cda91c606 Mon Sep 17 00:00:00 2001 From: Denis Doria Date: Fri, 3 Jun 2016 11:28:10 +0200 Subject: Put w to uppercase just to keep consistency between warnings --- sway/commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sway/commands.c b/sway/commands.c index e204fb40..90a7d421 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -3047,7 +3047,7 @@ static struct cmd_results *bar_cmd_swaybar_command(int argc, char **argv) { } static struct cmd_results *bar_cmd_tray_output(int argc, char **argv) { - sway_log(L_ERROR, "warning: tray_output is not supported on wayland"); + sway_log(L_ERROR, "Warning: tray_output is not supported on wayland"); return cmd_results_new(CMD_SUCCESS, NULL, NULL); } -- cgit v1.2.3-54-g00ecf