aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sway/commands.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/sway/commands.c b/sway/commands.c
index f6d56bb4..42105d5f 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -1401,17 +1401,34 @@ struct cmd_results *handle_command(char *_exec) {
1401 1401
1402 head = exec; 1402 head = exec;
1403 do { 1403 do {
1404 // Handle criteria 1404 // Extract criteria (valid for this command list only).
1405 criteria = NULL;
1405 if (*head == '[') { 1406 if (*head == '[') {
1407 ++head;
1406 criteria = argsep(&head, "]"); 1408 criteria = argsep(&head, "]");
1407 if (head) { 1409 if (head) {
1408 ++head; 1410 ++head;
1409 // TODO handle criteria 1411 // TODO handle criteria
1410 } else { 1412 } else {
1411 results = cmd_results_new(CMD_INVALID, NULL, "Unmatched ["); 1413 if (!results) {
1414 results = cmd_results_new(CMD_INVALID, criteria, "Unmatched [");
1415 }
1416 goto cleanup;
1412 } 1417 }
1413 // Skip leading whitespace 1418 // Skip leading whitespace
1414 head += strspn(head, whitespace); 1419 head += strspn(head, whitespace);
1420
1421 // TODO: it will yield unexpected results to execute commands
1422 // (on any view) that where meant for certain views only.
1423 if (!results) {
1424 int len = strlen(criteria) + strlen(head) + 4;
1425 char *tmp = malloc(len);
1426 snprintf(tmp, len, "[%s] %s", criteria, head);
1427 results = cmd_results_new(CMD_INVALID, tmp,
1428 "Can't handle criteria string: Refusing to execute command");
1429 free(tmp);
1430 }
1431 goto cleanup;
1415 } 1432 }
1416 // Split command list 1433 // Split command list
1417 cmdlist = argsep(&head, ";"); 1434 cmdlist = argsep(&head, ";");