From 7dd42c510dc8ab10f52dcc2d20dc8af412be0744 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Tue, 19 Jul 2016 15:06:58 +0200 Subject: 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 Signed-off-by: Richard Weinberger --- misc-utils/flash_unlock.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'misc-utils/flash_unlock.c') diff --git a/misc-utils/flash_unlock.c b/misc-utils/flash_unlock.c index f51870a..94f4761 100644 --- a/misc-utils/flash_unlock.c +++ b/misc-utils/flash_unlock.c @@ -46,7 +46,7 @@ static void usage(int status) "\n" "Options:\n" " -h --help Display this help and exit\n" - " --version Display version information and exit\n" + " -V --version Display version information and exit\n" " -i --islocked Check if flash region is locked\n" " -l --lock Lock a region of flash\n" " -u --unlock Unlock a region of flash\n" @@ -59,13 +59,13 @@ static void usage(int status) exit(status); } -static const char short_opts[] = "hilu"; +static const char short_opts[] = "hiluV"; static const struct option long_opts[] = { { "help", no_argument, 0, 'h' }, { "islocked", no_argument, 0, 'i' }, { "lock", no_argument, 0, 'l' }, { "unlock", no_argument, 0, 'u' }, - { "version", no_argument, 0, 'v' }, + { "version", no_argument, 0, 'V' }, { NULL, 0, 0, 0 }, }; @@ -101,7 +101,7 @@ static void process_args(int argc, char *argv[]) req = REQUEST_UNLOCK; req_set++; break; - case 'v': + case 'V': common_print_version(); exit(0); default: -- cgit v1.2.3