Print zdump and zic program names in --version output
This patch makes zdump and zic print their own names in their --version output, in accordance with the GNU standards for what --version should print. (tzselect already does print its name in --version output.) diff --git a/zdump.c b/zdump.c index 805267d..8b118ed 100644 --- a/zdump.c +++ b/zdump.c @@ -309,7 +309,7 @@ main(int argc, char *argv[]) progname = argv[0]; for (i = 1; i < argc; ++i) if (strcmp(argv[i], "--version") == 0) { - (void) printf("%s\n", TZVERSION); + (void) printf("zdump %s\n", TZVERSION); exit(EXIT_SUCCESS); } else if (strcmp(argv[i], "--help") == 0) { usage(stdout, EXIT_SUCCESS); diff --git a/zic.c b/zic.c index a9a54bb..428eaaa 100644 --- a/zic.c +++ b/zic.c @@ -462,7 +462,7 @@ main(int argc, char **argv) } for (i = 1; i < argc; ++i) if (strcmp(argv[i], "--version") == 0) { - (void) printf("%s\n", TZVERSION); + (void) printf("zic %s\n", TZVERSION); exit(EXIT_SUCCESS); } else if (strcmp(argv[i], "--help") == 0) { usage(stdout, EXIT_SUCCESS); -- Joseph S. Myers joseph@codesourcery.com
This patch makes zdump and zic print their own names in their --version output, in accordance with the GNU standards
Do the GNU standards call for the canonical name (for example, "zic") or for the name by which the command was invoked (as derived from the arguments to "main")? --ado On Fri, Nov 9, 2012 at 4:47 PM, Joseph S. Myers <jsm@polyomino.org.uk>wrote:
This patch makes zdump and zic print their own names in their --version output, in accordance with the GNU standards for what --version should print. (tzselect already does print its name in --version output.)
diff --git a/zdump.c b/zdump.c index 805267d..8b118ed 100644 --- a/zdump.c +++ b/zdump.c @@ -309,7 +309,7 @@ main(int argc, char *argv[]) progname = argv[0]; for (i = 1; i < argc; ++i) if (strcmp(argv[i], "--version") == 0) { - (void) printf("%s\n", TZVERSION); + (void) printf("zdump %s\n", TZVERSION); exit(EXIT_SUCCESS); } else if (strcmp(argv[i], "--help") == 0) { usage(stdout, EXIT_SUCCESS); diff --git a/zic.c b/zic.c index a9a54bb..428eaaa 100644 --- a/zic.c +++ b/zic.c @@ -462,7 +462,7 @@ main(int argc, char **argv) } for (i = 1; i < argc; ++i) if (strcmp(argv[i], "--version") == 0) { - (void) printf("%s\n", TZVERSION); + (void) printf("zic %s\n", TZVERSION); exit(EXIT_SUCCESS); } else if (strcmp(argv[i], "--help") == 0) { usage(stdout, EXIT_SUCCESS);
-- Joseph S. Myers joseph@codesourcery.com
On 11/09/2012 03:10 PM, Arthur David Olson wrote:
Do the GNU standards call for the canonical name (for example, "zic") or for the name by which the command was invoked (as derived from the arguments to "main")?
The former. Since zic and zdump are part of a larger package, the standards say that the output should be something like this zic (tz) 2012j as in the revised patch below. Or perhaps we should make that string "tzcode" rather than "tz"? Here's the chapter and verse for the coding standards: http://www.gnu.org/prep/standards/html_node/_002d_002dversion.html diff --git a/zdump.c b/zdump.c index 805267d..823ffa2 100644 --- a/zdump.c +++ b/zdump.c @@ -309,7 +309,7 @@ main(int argc, char *argv[]) progname = argv[0]; for (i = 1; i < argc; ++i) if (strcmp(argv[i], "--version") == 0) { - (void) printf("%s\n", TZVERSION); + (void) printf("zdump (tz) %s\n", TZVERSION); exit(EXIT_SUCCESS); } else if (strcmp(argv[i], "--help") == 0) { usage(stdout, EXIT_SUCCESS); diff --git a/zic.c b/zic.c index a9a54bb..9d4c422 100644 --- a/zic.c +++ b/zic.c @@ -462,7 +462,7 @@ main(int argc, char **argv) } for (i = 1; i < argc; ++i) if (strcmp(argv[i], "--version") == 0) { - (void) printf("%s\n", TZVERSION); + (void) printf("zic (tz) %s\n", TZVERSION); exit(EXIT_SUCCESS); } else if (strcmp(argv[i], "--help") == 0) { usage(stdout, EXIT_SUCCESS);
Here's an updated version of the proposed patch, which outputs the version info as something like "zic (tzcode) 2012i"; this follows the GNU coding standards more carefully.
From 89a60086d33916dc355325525b85381033b7e86e Mon Sep 17 00:00:00 2001 From: Paul Eggert <eggert@cs.ucla.edu> Date: Fri, 9 Nov 2012 18:12:22 -0800 Subject: [PATCH] Output version info in a more-typical format.
E.g., "zic (tzcode) 2012i" instead of "tzcode2012i". Thread started by Joseph S. Myers in <http://mm.icann.org/pipermail/tz/2012-November/018439.html>. * Makefile (PACKAGE): New macro. (version.h, tzselect): New constant PKGVERSION, derived from PACKAGE. (tzselect): TZVERSION is now simply VERSION, since PACKAGE is also output. * tzselect.ksh (PKGVERSION): New var, which Makefile substitutes for. (--usage, --version): Exit with nonzero status if we can't output the help or version number. * tzselect.ksh (--version): * zdump.c, zic.c (main): Output versions like this: "zdump (tzcode) 2012i". --- Makefile | 10 +++++++--- tzselect.ksh | 7 ++++--- zdump.c | 2 +- zic.c | 2 +- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index ea081a3..5a17164 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,9 @@ # This file is in the public domain, so clarified as of # 2009-05-17 by Arthur David Olson. +# Package name for the code distribution. +PACKAGE= tzcode + # Version numbers of the code and data distributions. VERSION= 2012i @@ -340,8 +343,8 @@ INSTALL: ALL install date.1 cp date.1 $(MANDIR)/man1/. version.h: - echo >$@ \ - 'static char const TZVERSION[]="tz$(VERSION)";' + (echo 'static char const PKGVERSION[]="($(PACKAGE)) ";' && \ + echo 'static char const TZVERSION[]="$(VERSION)";') >$@ zdump: $(TZDOBJS) $(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(TZDOBJS) $(LDLIBS) @@ -392,8 +395,9 @@ tzselect: tzselect.ksh sed \ -e 's|#!/bin/bash|#!$(KSHELL)|g' \ -e 's|AWK=[^}]*|AWK=$(AWK)|g' \ + -e 's|\(PKGVERSION\)=.*|\1='\''($(PACKAGE)) '\''|' \ -e 's|TZDIR=[^}]*|TZDIR=$(TZDIR)|' \ - -e 's|\(TZVERSION\)=.*|\1=tz$(VERSION)|' \ + -e 's|\(TZVERSION\)=.*|\1=$(VERSION)|' \ <$? >$@ chmod +x $@ diff --git a/tzselect.ksh b/tzselect.ksh index 279bdf2..51bafc1 100644 --- a/tzselect.ksh +++ b/tzselect.ksh @@ -1,5 +1,6 @@ #!/bin/bash +PKGVERSION='(tzcode) ' TZVERSION=see_Makefile # Ask the user about the time zone, and output the resulting TZ value to stdout. @@ -45,12 +46,12 @@ Select a time zone interactively. Report bugs to tz@iana.org. EOF - exit 0 + exit elif [ "$1" = "--version" ]; then cat <<EOF -tzselect $TZVERSION +tzselect $PKGVERSION$TZVERSION EOF - exit 0 + exit fi # Make sure the tables are readable. diff --git a/zdump.c b/zdump.c index bdbd1d6..626b09d 100644 --- a/zdump.c +++ b/zdump.c @@ -309,7 +309,7 @@ main(int argc, char *argv[]) progname = argv[0]; for (i = 1; i < argc; ++i) if (strcmp(argv[i], "--version") == 0) { - (void) printf("%s\n", TZVERSION); + (void) printf("zdump %s%s\n", PKGVERSION, TZVERSION); exit(EXIT_SUCCESS); } else if (strcmp(argv[i], "--help") == 0) { usage(stdout, EXIT_SUCCESS); diff --git a/zic.c b/zic.c index 35c8d4b..1964a89 100644 --- a/zic.c +++ b/zic.c @@ -462,7 +462,7 @@ main(int argc, char **argv) } for (i = 1; i < argc; ++i) if (strcmp(argv[i], "--version") == 0) { - (void) printf("%s\n", TZVERSION); + (void) printf("zic %s%s\n", PKGVERSION, TZVERSION); exit(EXIT_SUCCESS); } else if (strcmp(argv[i], "--help") == 0) { usage(stdout, EXIT_SUCCESS); -- 1.7.9.5
Date: Fri, 9 Nov 2012 21:47:54 +0000 (UTC) From: "Joseph S. Myers" <jsm@polyomino.org.uk> Message-ID: <Pine.LNX.4.64.1211092145080.25519@digraph.polyomino.org.uk> | in accordance with the GNU standards for what --version should print. I don't actually care what --version prints (though keeping it relatively constant - other than its value of course - over time, so any scripts that parse it don't have to keep being updated is a good idea). But why do we care about GNU standards? Sure, POSIX, and IEEE C make sense to follow, but GNU?? Why?? kre
On Sat, 10 Nov 2012, Robert Elz wrote:
But why do we care about GNU standards? Sure, POSIX, and IEEE C make sense to follow, but GNU?? Why??
The whole idea of --help and --version options is a GNU standard. Given that those options originate in GNU standards, it makes sense to follow the GNU standards in what they output. -- Joseph S. Myers joseph@codesourcery.com
On 2012-11-09 17:20, Paul Eggert wrote:
On 11/09/2012 03:54 PM, Robert Elz wrote:
why do we care about GNU standards?
We're talking about the --version option, which is a GNUish thing.
GNU standard you cited: http://www.gnu.org/prep/standards/html_node/_002d_002dversion.html also requires copyright(s) and licence(s) information to be appended. Package could also be named timezone or zoneinfo if preferred. IMHO tzcode is a distribution artifact, and useless without tzdata.
participants (5)
-
Arthur David Olson -
Brian Inglis -
Joseph S. Myers -
Paul Eggert -
Robert Elz