diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2016-07-19 15:06:58 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2016-11-17 11:36:55 +0100 |
commit | 7dd42c510dc8ab10f52dcc2d20dc8af412be0744 (patch) | |
tree | fa45022d4754db6a72285d7e9f9284e877ce06c5 /nand-utils/nandwrite.c | |
parent | 8a00021b2ab5529640e5acaca30a27cdaca04178 (diff) |
Unify version string printing
When a program does sophisticated enough command line processing
(i.e. getopt), make sure it responds to -V and --version.
When a program prints a version string, make sure it uses the
common_print_version macro to print out its name, that it is part
of mtd-utils and the mtd-utils version from the build system in a
fashion similar to common program packages like the GNU coreutils.
When a program responds to -V/--version or -h/--help, make sure it
reports success exit status.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'nand-utils/nandwrite.c')
-rw-r--r-- | nand-utils/nandwrite.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/nand-utils/nandwrite.c b/nand-utils/nandwrite.c index 9c3fe8f..1c00cdf 100644 --- a/nand-utils/nandwrite.c +++ b/nand-utils/nandwrite.c @@ -61,16 +61,15 @@ static void display_help(int status) " --input-size=length Only read |length| bytes of the input file\n" " -q, --quiet Don't display progress messages\n" " -h, --help Display this help and exit\n" -" --version Output version information and exit\n" +" -V, --version Output version information and exit\n" ); exit(status); } static void display_version(void) { - printf("%1$s " VERSION "\n" - "\n" - "Copyright (C) 2003 Thomas Gleixner \n" + common_print_version(); + printf("Copyright (C) 2003 Thomas Gleixner \n" "\n" "%1$s comes with NO WARRANTY\n" "to the extent permitted by law.\n" @@ -103,10 +102,10 @@ static void process_options(int argc, char * const argv[]) for (;;) { int option_index = 0; - static const char short_options[] = "hb:mnNoOpqs:a"; + static const char short_options[] = "hb:mnNoOpqs:aV"; static const struct option long_options[] = { /* Order of these args with val==0 matters; see option_index. */ - {"version", no_argument, 0, 0}, + {"version", no_argument, 0, 'V'}, {"input-skip", required_argument, 0, 0}, {"input-size", required_argument, 0, 0}, {"help", no_argument, 0, 'h'}, @@ -131,9 +130,6 @@ static void process_options(int argc, char * const argv[]) switch (c) { case 0: switch (option_index) { - case 0: /* --version */ - display_version(); - break; case 1: /* --input-skip */ inputskip = simple_strtoll(optarg, &error); break; @@ -142,6 +138,9 @@ static void process_options(int argc, char * const argv[]) break; } break; + case 'V': + display_version(); + break; case 'q': quiet = true; break; |