diff options
author | 2016-06-03 11:26:47 +0200 | |
---|---|---|
committer | 2016-06-03 11:26:47 +0200 | |
commit | bf2298e0a5265ede7a056f1247a4aab7e76f4b3d (patch) | |
tree | d1e4017ecc6d2bdebb8a45af38e8e407eb7ca25c /sway | |
parent | Fix identation issue (diff) | |
download | sway-bf2298e0a5265ede7a056f1247a4aab7e76f4b3d.tar.gz sway-bf2298e0a5265ede7a056f1247a4aab7e76f4b3d.tar.zst sway-bf2298e0a5265ede7a056f1247a4aab7e76f4b3d.zip |
Includes $ for variables without it
Diffstat (limited to 'sway')
-rw-r--r-- | sway/commands.c | 12 |
1 files changed, 11 insertions, 1 deletions
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) { | |||
2146 | } | 2146 | } |
2147 | 2147 | ||
2148 | static struct cmd_results *cmd_set(int argc, char **argv) { | 2148 | static struct cmd_results *cmd_set(int argc, char **argv) { |
2149 | char *tmp; | ||
2150 | int size; | ||
2149 | struct cmd_results *error = NULL; | 2151 | struct cmd_results *error = NULL; |
2150 | if (!config->reading) return cmd_results_new(CMD_FAILURE, "set", "Can only be used in config file."); | 2152 | if (!config->reading) return cmd_results_new(CMD_FAILURE, "set", "Can only be used in config file."); |
2151 | if ((error = checkarg(argc, "set", EXPECTED_AT_LEAST, 2))) { | 2153 | if ((error = checkarg(argc, "set", EXPECTED_AT_LEAST, 2))) { |
@@ -2153,7 +2155,15 @@ static struct cmd_results *cmd_set(int argc, char **argv) { | |||
2153 | } | 2155 | } |
2154 | 2156 | ||
2155 | if (argv[0][0] != '$') { | 2157 | if (argv[0][0] != '$') { |
2156 | return cmd_results_new(CMD_FAILURE, "set", "Malformed variable assignment, name has to start with $"); | 2158 | sway_log(L_INFO, "Warning: variable '%s' doesn't start with $", argv[0]); |
2159 | |||
2160 | size = asprintf(&tmp, "%s%s", "$", argv[0]); | ||
2161 | if (size == -1) { | ||
2162 | return cmd_results_new(CMD_FAILURE, "set", "Not possible to create variable $'%s'", argv[0]); | ||
2163 | } | ||
2164 | |||
2165 | argv[0] = strdup(tmp); | ||
2166 | free(tmp); | ||
2157 | } | 2167 | } |
2158 | 2168 | ||
2159 | struct sway_variable *var = NULL; | 2169 | struct sway_variable *var = NULL; |