|
|
|
@ -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;
|
|
|
|
|