* Fixes a regression
* In addition allows --help to be specified before the command. If
a command is present, command help will be shown
https://bugs.freedesktop.org/show_bug.cgi?id=62153
main (int argc, char *argv[])
{
char *command = NULL;
+ bool want_help = false;
bool skip;
int in, out;
int i;
quiet_arg ();
} else if (strcmp (argv[in], "--help") == 0) {
- command_usage ();
- return 0;
+ want_help = true;
} else if (!command) {
p11_message ("unknown global option: %s", argv[in]);
for (i = 1; argv[in][i] != '\0'; i++) {
switch (argv[in][i]) {
case 'h':
- command_usage ();
- return 0;
+ want_help = true;
+ break;
/* Compatibility option */
case 'l':
if (command == NULL) {
/* As a special favor if someone just typed 'p11-kit', help them out */
- if (argc == 1)
+ if (argc == 1) {
command_usage ();
- else
+ return 2;
+ } else if (want_help) {
+ command_usage ();
+ return 0;
+ } else {
p11_message ("no command specified");
- return 2;
+ return 2;
+ }
}
argc = out;