From 6bcfa0c4ecf974851e5246d1d90a60640a09164f Mon Sep 17 00:00:00 2001 From: Tony Finch Date: Mon, 7 Mar 2022 17:07:45 +0000 Subject: [PATCH 1/2] Consistently print version numbers to stdout Since the user asked for the version number it is logical to make it a non-error, i.e. print to stdout (not stderr) and exit(0). Closes #3189 --- CHANGES | 5 +++++ bin/delv/delv.c | 2 +- bin/dig/dig.c | 8 +------- bin/dig/host.c | 8 +------- bin/dig/nslookup.c | 7 +------ bin/dnssec/dnssectool.c | 2 +- bin/nsupdate/nsupdate.c | 7 +------ bin/tools/mdig.c | 2 +- 8 files changed, 12 insertions(+), 29 deletions(-) diff --git a/CHANGES b/CHANGES index 3a2ee1217f..5e1e313964 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,8 @@ +5827. [cleanup] The command-line utilities printed their version numbers + inconsistently; they all now print to stdout. (They are + still inconsistent abotut whether you use `-v` or `-V` + to request the version). [GL #3189] + 5826. [cleanup] Stop dig from complaining about lack of IDN support when the user asks for no IDN translation. [GL #3188] diff --git a/bin/delv/delv.c b/bin/delv/delv.c index e98c551bbd..be77cb1f53 100644 --- a/bin/delv/delv.c +++ b/bin/delv/delv.c @@ -1334,7 +1334,7 @@ dash_option(char *option, char *next, bool *open_type_class) { /* handled in preparse_args() */ break; case 'v': - fprintf(stderr, "delv %s\n", PACKAGE_VERSION); + printf("delv %s\n", PACKAGE_VERSION); exit(0); /* NOTREACHED */ default: diff --git a/bin/dig/dig.c b/bin/dig/dig.c index 756d38b0e8..fbaf7e1d23 100644 --- a/bin/dig/dig.c +++ b/bin/dig/dig.c @@ -125,12 +125,6 @@ usage(void) { } #endif /* if TARGET_OS_IPHONE */ -/*% version */ -static void -version(void) { - fprintf(stderr, "DiG %s\n", PACKAGE_VERSION); -} - /*% help */ static void help(void) { @@ -2164,7 +2158,7 @@ dash_option(char *option, char *next, dig_lookup_t **lookup, (*lookup)->use_usec = true; break; case 'v': - version(); + printf("DiG %s\n", PACKAGE_VERSION); exit(0); break; } diff --git a/bin/dig/host.c b/bin/dig/host.c index bfc54c646a..775cddf37e 100644 --- a/bin/dig/host.c +++ b/bin/dig/host.c @@ -584,12 +584,6 @@ printmessage(dig_query_t *query, const isc_buffer_t *msgbuf, dns_message_t *msg, static const char *optstring = "46aAc:dilnm:p:rst:vVwCDN:R:TUW:"; -/*% version */ -static void -version(void) { - fprintf(stderr, "host %s\n", PACKAGE_VERSION); -} - static void pre_parse_args(int argc, char **argv) { int c; @@ -663,7 +657,7 @@ pre_parse_args(int argc, char **argv) { case 'v': break; case 'V': - version(); + printf("host %s\n", PACKAGE_VERSION); exit(0); break; case 'w': diff --git a/bin/dig/nslookup.c b/bin/dig/nslookup.c index d5ce6f7900..742bb7851a 100644 --- a/bin/dig/nslookup.c +++ b/bin/dig/nslookup.c @@ -612,11 +612,6 @@ set_ndots(const char *value) { } } -static void -version(void) { - fprintf(stderr, "nslookup %s\n", PACKAGE_VERSION); -} - static void setoption(char *opt) { size_t l = strlen(opt); @@ -880,7 +875,7 @@ parse_args(int argc, char **argv) { debug("main parsing %s", argv[0]); if (argv[0][0] == '-') { if (strncasecmp(argv[0], "-ver", 4) == 0) { - version(); + printf("nslookup %s\n", PACKAGE_VERSION); exit(0); } else if (argv[0][1] != 0) { setoption(&argv[0][1]); diff --git a/bin/dnssec/dnssectool.c b/bin/dnssec/dnssectool.c index 5908aa7df5..38e21c7b76 100644 --- a/bin/dnssec/dnssectool.c +++ b/bin/dnssec/dnssectool.c @@ -111,7 +111,7 @@ vbprintf(int level, const char *fmt, ...) { void version(const char *name) { - fprintf(stderr, "%s %s\n", name, PACKAGE_VERSION); + printf("%s %s\n", name, PACKAGE_VERSION); exit(0); } diff --git a/bin/nsupdate/nsupdate.c b/bin/nsupdate/nsupdate.c index b0af713923..7b6b4f8d5b 100644 --- a/bin/nsupdate/nsupdate.c +++ b/bin/nsupdate/nsupdate.c @@ -976,11 +976,6 @@ get_addresses(char *host, in_port_t port, isc_sockaddr_t *sockaddr, return (count); } -static void -version(void) { - fprintf(stderr, "nsupdate %s\n", PACKAGE_VERSION); -} - #define PARSE_ARGS_FMT "46C:dDghilL:Mok:p:Pr:R:t:Tu:vVy:" static void @@ -1055,7 +1050,7 @@ pre_parse_args(int argc, char **argv) { break; case 'V': - version(); + printf("nsupdate %s\n", PACKAGE_VERSION); doexit = true; break; diff --git a/bin/tools/mdig.c b/bin/tools/mdig.c index 4da54e15ee..a8dd85da38 100644 --- a/bin/tools/mdig.c +++ b/bin/tools/mdig.c @@ -1726,7 +1726,7 @@ dash_option(const char *option, char *next, struct query *query, bool global, */ break; case 'v': - fprintf(stderr, "mDiG %s\n", PACKAGE_VERSION); + printf("mDiG %s\n", PACKAGE_VERSION); exit(0); break; } From 338df9e1ff85d43bbab4d1f78eae7f49cb1376b5 Mon Sep 17 00:00:00 2001 From: Tony Finch Date: Mon, 7 Mar 2022 17:12:30 +0000 Subject: [PATCH 2/2] Correct spelling of dnssec-signzone in output file The version comment in the signed zone said "dnssec_signzone". To fix it, use the same `program` variable as other warnings and messages. --- bin/dnssec/dnssec-signzone.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/dnssec/dnssec-signzone.c b/bin/dnssec/dnssec-signzone.c index cf203b1276..8fc6eee5b6 100644 --- a/bin/dnssec/dnssec-signzone.c +++ b/bin/dnssec/dnssec-signzone.c @@ -3189,7 +3189,7 @@ print_version(FILE *fp) { return; } - fprintf(fp, "; dnssec_signzone version %s\n", PACKAGE_VERSION); + fprintf(fp, "; %s version %s\n", program, PACKAGE_VERSION); } ISC_NORETURN static void