Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Fri, 6 Jul 2012 18:50:57 +0200
From: Frank Dittrich <frank_dittrich@...mail.com>
To: john-dev@...ts.openwall.com
Subject: Add --help option to john (was: Would supporting ./john --help be
 a good idea?)

On 07/06/2012 11:49 AM, magnum wrote:
> OK, I think it's a bad thing we diverge more than needed from core. It's
> hard to follow, and hard to merge core changes.

I thought so.
That's why I used an additional opt_init() parameter.
(There was a second caller of opt_init() in recovery.c.)

I didn't change doc/OPTIONS. because the newly introduced parameter
--help doesn't allow any other abbreviation than -h or -help.
I didn't want to make the new logic overly complicated, and I didn't
want to describe the differences between --help and all the other
options in too much detail.
Anyway, those people reading doc/OPTIONS will know they can use john
without any parameters.
Those using bash completion will get
$ ./john -[tab]
completed to
$ ./john --
and
$ ./john --[tab][tab]
will list "--help" as one of the possible completions.


I put --help in front of --list=hidden-options:

$ ./john --list=hidden-options
--help                    print usage summary, just like running the command
                          without any parameters
--subformat=FORMAT        pick a benchmark format for --format=crypt
...

I thought using two lines for the description is OK, since we are not
yet running out of space here.
(The bash completion script doesn't need to be changed to handle this case.)

Should I rephrase the description in some way?


I didn't include my other idea into the patch.
While this looks OK:

 $ ./john --whatever
Unknown option: "--whatever", see "./john --help"

In other cases, it is questionable whether the changed output really helps:

$ ./john --rules=single
Invalid options combination or duplicate option: "--rules=single", see
"./john --help"


If you think this change is helpful nevertheless, I can turn my not yet
committed changes into a patch:

$ git diff
diff --git a/src/getopt.c b/src/getopt.c
index b2e373b..e1f9ee1 100644
--- a/src/getopt.c
+++ b/src/getopt.c
@@ -130,7 +130,8 @@ void opt_process(struct opt_entry *list, opt_flags
*flg, char **argv)
 #ifdef HAVE_MPI
                if (mpi_id == 0)
 #endif
-               fprintf(stderr, "%s: \"%s\"\n", opt_errors[res], *opt);
+               fprintf(stderr, "%s: \"%s\", see \"%s --help\"\n",
+                               opt_errors[res], *opt, argv[0]);
                error();
        }
 }
@@ -146,7 +147,8 @@ void opt_check(struct opt_entry *list, opt_flags
flg, char **argv)
 #ifdef HAVE_MPI
                if (mpi_id == 0)
 #endif
-               fprintf(stderr, "%s: \"%s\"\n", opt_errors[res], *opt);
+               fprintf(stderr, "%s: \"%s\", see \"%s --help\"\n",
+                               opt_errors[res], *opt, argv[0]);
                error();
        }
 }


Frank

View attachment "0001-Add-help-option-to-john-prints-usage-summary.patch" of type "text/x-patch" (2998 bytes)

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.