Does anyone know of a tool using parse_long_options() which would rely on printing the --version text right after the usage text for the --help option?
Otherwise ... see patch below. Have a nice day, Berny >From f75f6dd2671231c880ee9cf040ccebaf7c58b6c0 Mon Sep 17 00:00:00 2001 From: Bernhard Voelker <m...@bernhard-voelker.de> Date: Thu, 17 Jul 2014 00:30:28 +0200 Subject: [PATCH] parse_long_options: after --help, avoid fallthrough into --version * lib/long-options.c (parse_long_options): Add exit() with EXIT_SUCCESS after invoking the given usage function - just in case the usage_func would not exit(). Spotted by coverity. While at it, pass EXIT_SUCCESS rather than 0 in the --version case for clarity. --- ChangeLog | 9 +++++++++ lib/long-options.c | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e3d86b3..b9b0a94 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2014-07-17 Bernhard Voelker <m...@bernhard-voelker.de> + + parse_long_options: after --help, avoid fallthrough into --version + * lib/long-options.c (parse_long_options): Add exit() with + EXIT_SUCCESS after invoking the given usage function - just in case + the usage_func would not exit(). Spotted by coverity. + While at it, pass EXIT_SUCCESS rather than 0 in the --version case + for clarity. + 2014-07-14 Daiki Ueno <u...@gnu.org> announce-gen: avoid failure when Digest::SHA is installed diff --git a/lib/long-options.c b/lib/long-options.c index fa7d1cd..779ae75 100644 --- a/lib/long-options.c +++ b/lib/long-options.c @@ -64,13 +64,14 @@ parse_long_options (int argc, { case 'h': (*usage_func) (EXIT_SUCCESS); + exit (EXIT_SUCCESS); case 'v': { va_list authors; va_start (authors, usage_func); version_etc_va (stdout, command_name, package, version, authors); - exit (0); + exit (EXIT_SUCCESS); } default: -- 1.8.4.5