aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/workspace.c
diff options
context:
space:
mode:
authorLibravatar Ian Fan <ianfan0@gmail.com>2018-08-12 00:32:13 +0100
committerLibravatar Ian Fan <ianfan0@gmail.com>2018-08-18 17:25:06 +0100
commite81cc8a5754386d9484b84cf97ab2f8755c35294 (patch)
treea3a9f64d0e179b07f94e2fff1484f5099f440432 /sway/commands/workspace.c
parentcommands: handle quoted exec command (diff)
downloadsway-e81cc8a5754386d9484b84cf97ab2f8755c35294.tar.gz
sway-e81cc8a5754386d9484b84cf97ab2f8755c35294.tar.zst
sway-e81cc8a5754386d9484b84cf97ab2f8755c35294.zip
commands: saner workspace number handling
Diffstat (limited to 'sway/commands/workspace.c')
-rw-r--r--sway/commands/workspace.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/sway/commands/workspace.c b/sway/commands/workspace.c
index f5558bb4..ceb4cd6e 100644
--- a/sway/commands/workspace.c
+++ b/sway/commands/workspace.c
@@ -1,4 +1,5 @@
1#define _XOPEN_SOURCE 500 1#define _XOPEN_SOURCE 500
2#include <ctype.h>
2#include <string.h> 3#include <string.h>
3#include <strings.h> 4#include <strings.h>
4#include "sway/commands.h" 5#include "sway/commands.h"
@@ -60,9 +61,13 @@ struct cmd_results *cmd_workspace(int argc, char **argv) {
60 struct sway_container *ws = NULL; 61 struct sway_container *ws = NULL;
61 if (strcasecmp(argv[0], "number") == 0) { 62 if (strcasecmp(argv[0], "number") == 0) {
62 if (argc < 2) { 63 if (argc < 2) {
63 cmd_results_new(CMD_INVALID, "workspace", 64 return cmd_results_new(CMD_INVALID, "workspace",
64 "Expected workspace number"); 65 "Expected workspace number");
65 } 66 }
67 if (!isdigit(argv[1][0])) {
68 return cmd_results_new(CMD_INVALID, "workspace",
69 "Invalid workspace number '%s'", argv[1]);
70 }
66 if (!(ws = workspace_by_number(argv[1]))) { 71 if (!(ws = workspace_by_number(argv[1]))) {
67 char *name = join_args(argv + 1, argc - 1); 72 char *name = join_args(argv + 1, argc - 1);
68 ws = workspace_create(NULL, name); 73 ws = workspace_create(NULL, name);