mirror of
https://github.com/swaywm/sway.git
synced 2024-12-29 08:26:45 +01:00
Merge pull request #693 from thuck/variables_corner_cases
Variables related fixes
This commit is contained in:
commit
2e10f0abbc
1 changed files with 16 additions and 2 deletions
|
@ -1632,7 +1632,7 @@ static struct cmd_results *cmd_output(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
char *src = join_args(argv + i, argc - i - 1);
|
char *src = join_args(argv + i, argc - i - 1);
|
||||||
char *mode = argv[argc - 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);
|
return cmd_results_new(CMD_INVALID, "output", "Invalid syntax (%s)", src);
|
||||||
}
|
}
|
||||||
free(src);
|
free(src);
|
||||||
|
@ -2146,12 +2146,26 @@ static int compare_set_qsort(const void *_l, const void *_r) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cmd_results *cmd_set(int argc, char **argv) {
|
static struct cmd_results *cmd_set(int argc, char **argv) {
|
||||||
|
char *tmp;
|
||||||
|
int size;
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results *error = NULL;
|
||||||
if (!config->reading) return cmd_results_new(CMD_FAILURE, "set", "Can only be used in config file.");
|
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))) {
|
if ((error = checkarg(argc, "set", EXPECTED_AT_LEAST, 2))) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (argv[0][0] != '$') {
|
||||||
|
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;
|
struct sway_variable *var = NULL;
|
||||||
// Find old variable if it exists
|
// Find old variable if it exists
|
||||||
int i;
|
int i;
|
||||||
|
@ -3033,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) {
|
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);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue