aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/bar.c
diff options
context:
space:
mode:
authorLibravatar Alyssa Ross <hi@alyssa.is>2019-05-17 00:13:41 +0000
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-05-19 11:47:16 -0400
commite4f1ffe6015fbd33994a18f1de65cbd62c177a83 (patch)
tree3a0e40cdd850ff8081484b374d2bbd040d2420bd /sway/commands/bar.c
parentbar: fix segfault with missing or invalid bar id (diff)
downloadsway-e4f1ffe6015fbd33994a18f1de65cbd62c177a83.tar.gz
sway-e4f1ffe6015fbd33994a18f1de65cbd62c177a83.tar.zst
sway-e4f1ffe6015fbd33994a18f1de65cbd62c177a83.zip
commands/bar: improve error for invalid subcommand
Running a command like this produced a confusing error message: $ swaymsg bar bar-0 colors background #ff0000 Error: Unknown/invalid command 'bar-0' This patch makes the error message use argv[1] instead of argv[0] (from config_subcommand's implementation), so it actually uses the name of the command, rather than the id of the bar.
Diffstat (limited to 'sway/commands/bar.c')
-rw-r--r--sway/commands/bar.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/sway/commands/bar.c b/sway/commands/bar.c
index 9c7357dd..88649bab 100644
--- a/sway/commands/bar.c
+++ b/sway/commands/bar.c
@@ -80,6 +80,13 @@ struct cmd_results *cmd_bar(int argc, char **argv) {
80 } 80 }
81 config->current_bar = bar; 81 config->current_bar = bar;
82 ++argv; --argc; 82 ++argv; --argc;
83 } else if (!config->reading) {
84 if (is_subcommand(argv[0])) {
85 return cmd_results_new(CMD_INVALID, "No bar defined.");
86 } else {
87 return cmd_results_new(CMD_INVALID,
88 "Unknown/invalid command '%s'", argv[1]);
89 }
83 } 90 }
84 91
85 if (!config->current_bar) { 92 if (!config->current_bar) {
@@ -103,8 +110,6 @@ struct cmd_results *cmd_bar(int argc, char **argv) {
103 // Set current bar 110 // Set current bar
104 config->current_bar = bar; 111 config->current_bar = bar;
105 sway_log(SWAY_DEBUG, "Creating bar %s", bar->id); 112 sway_log(SWAY_DEBUG, "Creating bar %s", bar->id);
106 } else {
107 return cmd_results_new(CMD_FAILURE, "No bar defined.");
108 } 113 }
109 } 114 }
110 115