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'.
This commit is contained in:
Christoph Gysin 2015-11-28 16:35:44 +02:00
parent bf97a5ada5
commit 923c3245ac
3 changed files with 8 additions and 11 deletions

View file

@ -128,10 +128,10 @@ int main(int argc, char **argv) {
static struct option long_options[] = {
{"help", no_argument, NULL, 'h'},
{"capture", no_argument, &capture, 'c'},
{"capture", no_argument, NULL, 'c'},
{"version", no_argument, NULL, 'v'},
{"socket", required_argument, NULL, 's'},
{"raw", no_argument, &raw, 'r'},
{"raw", no_argument, NULL, 'r'},
{"rate", required_argument, NULL, 'R'},
{0, 0, 0, 0}
};
@ -154,8 +154,6 @@ int main(int argc, char **argv) {
break;
}
switch (c) {
case 0: // Flag
break;
case 's': // Socket
socket_path = strdup(optarg);
break;