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 /sway | |
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 'sway')
-rw-r--r-- | sway/main.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/sway/main.c b/sway/main.c index 473a0990..1261a7ce 100644 --- a/sway/main.c +++ b/sway/main.c | |||
@@ -57,10 +57,10 @@ int main(int argc, char **argv) { | |||
57 | static struct option long_options[] = { | 57 | static struct option long_options[] = { |
58 | {"help", no_argument, NULL, 'h'}, | 58 | {"help", no_argument, NULL, 'h'}, |
59 | {"config", required_argument, NULL, 'c'}, | 59 | {"config", required_argument, NULL, 'c'}, |
60 | {"validate", no_argument, &validate, 1}, | 60 | {"validate", no_argument, NULL, 'C'}, |
61 | {"debug", no_argument, &debug, 1}, | 61 | {"debug", no_argument, NULL, 'd'}, |
62 | {"version", no_argument, NULL, 'v'}, | 62 | {"version", no_argument, NULL, 'v'}, |
63 | {"verbose", no_argument, &verbose, 1}, | 63 | {"verbose", no_argument, NULL, 'V'}, |
64 | {"get-socketpath", no_argument, NULL, 'p'}, | 64 | {"get-socketpath", no_argument, NULL, 'p'}, |
65 | {0, 0, 0, 0} | 65 | {0, 0, 0, 0} |
66 | }; | 66 | }; |
@@ -87,8 +87,6 @@ int main(int argc, char **argv) { | |||
87 | break; | 87 | break; |
88 | } | 88 | } |
89 | switch (c) { | 89 | switch (c) { |
90 | case 0: // Flag | ||
91 | break; | ||
92 | case 'h': // help | 90 | case 'h': // help |
93 | fprintf(stdout, "%s", usage); | 91 | fprintf(stdout, "%s", usage); |
94 | exit(EXIT_SUCCESS); | 92 | exit(EXIT_SUCCESS); |