diff options
author | Christoph Gysin <christoph.gysin@gmail.com> | 2015-11-28 16:35:44 +0200 |
---|---|---|
committer | Christoph Gysin <christoph.gysin@gmail.com> | 2015-11-28 23:50:44 +0200 |
commit | 923c3245ace71ea0e26a0b12746a699fa499f759 (patch) | |
tree | b3fe2cdbd20aa595dc4d4d4c5093172cce1d4054 /swaymsg | |
parent | swaymsg: Add --help option that prints usage (diff) | |
download | sway-923c3245ace71ea0e26a0b12746a699fa499f759.tar.gz sway-923c3245ace71ea0e26a0b12746a699fa499f759.tar.zst sway-923c3245ace71ea0e26a0b12746a699fa499f759.zip |
Fix option parsing
Using 'flag' results in duplicate code paths for short and long options.
This broke the -q short option in swaymsg, because there was:
{"quiet", no_argument, &quiet, 'q'}
Which will set quiet to 'q' and return 0, not 'q'.
Diffstat (limited to 'swaymsg')
-rw-r--r-- | swaymsg/main.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/swaymsg/main.c b/swaymsg/main.c index 8f91dc55..f8c9e14c 100644 --- a/swaymsg/main.c +++ b/swaymsg/main.c | |||
@@ -24,7 +24,7 @@ int main(int argc, char **argv) { | |||
24 | 24 | ||
25 | static struct option long_options[] = { | 25 | static struct option long_options[] = { |
26 | {"help", no_argument, NULL, 'h'}, | 26 | {"help", no_argument, NULL, 'h'}, |
27 | {"quiet", no_argument, &quiet, 'q'}, | 27 | {"quiet", no_argument, NULL, 'q'}, |
28 | {"version", no_argument, NULL, 'v'}, | 28 | {"version", no_argument, NULL, 'v'}, |
29 | {"socket", required_argument, NULL, 's'}, | 29 | {"socket", required_argument, NULL, 's'}, |
30 | {"type", required_argument, NULL, 't'}, | 30 | {"type", required_argument, NULL, 't'}, |
@@ -48,7 +48,8 @@ int main(int argc, char **argv) { | |||
48 | break; | 48 | break; |
49 | } | 49 | } |
50 | switch (c) { | 50 | switch (c) { |
51 | case 0: // Flag | 51 | case 'q': // Quiet |
52 | quiet = 1; | ||
52 | break; | 53 | break; |
53 | case 's': // Socket | 54 | case 's': // Socket |
54 | socket_path = strdup(optarg); | 55 | socket_path = strdup(optarg); |