summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2018-11-01 09:39:49 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2018-11-07 05:03:52 +0000
commit36af7d312b5b10790bd19e3066eb1cd4e4e5f6d4 (patch)
tree0408d63810d5e99dcd52eebe65e4f935606fe01d /tools
parentbd52bf542119f0cc71f7b676f9ed67d5001c40fc (diff)
downloadlibinput-36af7d312b5b10790bd19e3066eb1cd4e4e5f6d4.tar.gz
tools: make the tools exit with exit code 2 on usage issues
This makes it easier to test for usage issues Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'tools')
-rw-r--r--tools/libinput-debug-events.c12
-rw-r--r--tools/libinput-debug-gui.c10
-rw-r--r--tools/libinput-list-devices.c2
-rw-r--r--tools/libinput-tool.c4
-rw-r--r--tools/shared.c2
-rw-r--r--tools/shared.h2
6 files changed, 17 insertions, 15 deletions
diff --git a/tools/libinput-debug-events.c b/tools/libinput-debug-events.c
index 4f2f9999..42dadefa 100644
--- a/tools/libinput-debug-events.c
+++ b/tools/libinput-debug-events.c
@@ -944,11 +944,11 @@ main(int argc, char **argv)
switch(c) {
case '?':
- exit(1);
+ exit(EXIT_INVALID_USAGE);
break;
case 'h':
usage();
- exit(0);
+ exit(EXIT_SUCCESS);
break;
case OPT_SHOW_KEYCODES:
show_keycodes = true;
@@ -973,7 +973,7 @@ main(int argc, char **argv)
default:
if (tools_parse_option(c, optarg, &options) != 0) {
usage();
- return 1;
+ return EXIT_INVALID_USAGE;
}
break;
}
@@ -982,7 +982,7 @@ main(int argc, char **argv)
if (optind < argc) {
usage();
- return 1;
+ return EXIT_INVALID_USAGE;
}
memset(&act, 0, sizeof(act));
@@ -997,11 +997,11 @@ main(int argc, char **argv)
li = tools_open_backend(backend, seat_or_device, verbose, &grab);
if (!li)
- return 1;
+ return EXIT_FAILURE;
mainloop(li);
libinput_unref(li);
- return 0;
+ return EXIT_SUCCESS;
}
diff --git a/tools/libinput-debug-gui.c b/tools/libinput-debug-gui.c
index 62f0aec5..afe0a325 100644
--- a/tools/libinput-debug-gui.c
+++ b/tools/libinput-debug-gui.c
@@ -968,7 +968,7 @@ main(int argc, char **argv)
switch(c) {
case '?':
- exit(1);
+ exit(EXIT_INVALID_USAGE);
break;
case 'h':
usage();
@@ -991,7 +991,7 @@ main(int argc, char **argv)
default:
if (tools_parse_option(c, optarg, &options) != 0) {
usage();
- return 1;
+ return EXIT_INVALID_USAGE;
}
break;
}
@@ -1000,12 +1000,12 @@ main(int argc, char **argv)
if (optind < argc) {
usage();
- return 1;
+ return EXIT_INVALID_USAGE;
}
li = tools_open_backend(backend, seat_or_device, verbose, &w.grab);
if (!li)
- return 1;
+ return EXIT_FAILURE;
libinput_set_user_data(li, &w);
@@ -1019,5 +1019,5 @@ main(int argc, char **argv)
window_cleanup(&w);
libinput_unref(li);
- return 0;
+ return EXIT_SUCCESS;
}
diff --git a/tools/libinput-list-devices.c b/tools/libinput-list-devices.c
index 5fa17885..4b06452e 100644
--- a/tools/libinput-list-devices.c
+++ b/tools/libinput-list-devices.c
@@ -388,7 +388,7 @@ main(int argc, char **argv)
return 0;
} else {
usage();
- return 1;
+ return EXIT_INVALID_USAGE;
}
}
diff --git a/tools/libinput-tool.c b/tools/libinput-tool.c
index 30a64c27..7195de04 100644
--- a/tools/libinput-tool.c
+++ b/tools/libinput-tool.c
@@ -98,13 +98,13 @@ main(int argc, char **argv)
return EXIT_SUCCESS;
default:
usage();
- return EXIT_FAILURE;
+ return EXIT_INVALID_USAGE;
}
}
if (optind >= argc) {
usage();
- return EXIT_FAILURE;
+ return EXIT_INVALID_USAGE;
}
argv += optind;
diff --git a/tools/shared.c b/tools/shared.c
index e3bc0287..812870f6 100644
--- a/tools/shared.c
+++ b/tools/shared.c
@@ -576,7 +576,7 @@ tools_exec_command(const char *prefix, int real_argc, char **real_argv)
"libinput: %s is not a libinput command or not installed. "
"See 'libinput --help'\n",
command);
-
+ return EXIT_INVALID_USAGE;
} else {
fprintf(stderr,
"Failed to execute '%s' (%s)\n",
diff --git a/tools/shared.h b/tools/shared.h
index 7888d265..4e363e22 100644
--- a/tools/shared.h
+++ b/tools/shared.h
@@ -30,6 +30,8 @@
#include <quirks.h>
#include <libinput.h>
+#define EXIT_INVALID_USAGE 2
+
enum configuration_options {
OPT_TAP_ENABLE = 256,
OPT_TAP_DISABLE,