diff options
| author | Sean Kurtz <seankurtz75@gmail.com> | 2026-11-24 23:57:53 -0600 |
|---|---|---|
| committer | Sean Kurtz <seankurtz75@gmail.com> | 2026-11-24 23:57:53 -0600 |
| commit | c0082e03976935b1b1ebf389c8f3053ed1668e9e (patch) | |
| tree | 1857f78ace62701461822995efbe8e8c156701ef | |
| parent | 7d98bfa40e112c099e9a598656bd2203001570e1 (diff) | |
| download | whoson-c0082e03976935b1b1ebf389c8f3053ed1668e9e.tar.gz | |
whoson: report its version, and keep it in the Makefile
--version and -V print "whoson <version>"; the string comes from VERSION in
the Makefile through -DWHOSON_VERSION, so a hand compile still builds and
says "unknown". The release workflow refuses a tag that disagrees with it.
| -rw-r--r-- | Makefile | 5 | ||||
| -rw-r--r-- | whoson.c | 14 |
2 files changed, 16 insertions, 3 deletions
@@ -34,11 +34,14 @@ ZOAU_HOME = /usr/lpp/IBM/zoautil PREFIX = $(HOME)/.local BINDIR = $(PREFIX)/bin +# The release workflow refuses a tag that does not match this, and the binary +# reports it through --version. +VERSION = 1.0.0 CCDIR = /usr/lpp/IBM/cnw/v2r2/openxl/bin CC = $(CCDIR)/ibm-clang LISTFMT = $(CCDIR)/ibm-clang-listing-formatter CPPFLAGS = -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=200809L -D_ALL_SOURCE \ - -D_EXT + -D_EXT -DWHOSON_VERSION=\"$(VERSION)\" CFLAGS = -std=c17 -O3 -m64 -fzos-le-char-mode=ascii -Wall -Wextra \ -Wpedantic -Wshadow -Wconversion -I$(ZOAU_HOME)/include ZOAU_DLL = $(ZOAU_HOME)/lib/zoautil.x @@ -43,6 +43,11 @@ #define MAX_TOKENS 16 #define MAX_ARGS 64 + +/* Set by the Makefile from its VERSION, so the binary and the tag agree. */ +#ifndef WHOSON_VERSION +#define WHOSON_VERSION "unknown" +#endif #define MAX_PROCS 8192 #define MAX_ROWS 256 #define NAME_LEN 16 @@ -86,12 +91,13 @@ struct row { }; static const char usage_text[] = - "usage: whoson\n" + "usage: whoson [--help | --version]\n" "\n" "List logged-on users with session type (TSO/E or SSH).\n" "\n" "Options:\n" - " -h, --help show this help and exit\n"; + " -h, --help show this help and exit\n" + " -V, --version show the version and exit\n"; /* Write a message in the character set its destination expects. CEE converts * stdio output from ASCII to EBCDIC when the stream is a terminal, and sshd @@ -530,6 +536,10 @@ int main(int argc, char *argv[]) { emit_str(STDOUT_FILENO, usage_text); return 0; } + if (strcmp(argv[1], "-V") == 0 || strcmp(argv[1], "--version") == 0) { + emit_str(STDOUT_FILENO, "whoson " WHOSON_VERSION "\n"); + return 0; + } return usage_error("unknown argument"); } |
