From d12370568f1898033effed1559592c2bc29a6f37 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Sun, 30 Jan 2022 11:00:29 +0100 Subject: [PATCH] initctl: add -v,--version command line option This patch adds the -v,--version option to initctl, which acts as an alias to the 'version' command. For now they end up in the same old function, printing the program version. However, in time this will be changed so that the 'version' command asks a running Finit for its version instead of assuming the daemon is of the same version. Signed-off-by: Joachim Wiberg --- man/initctl.8 | 10 +++++++--- src/initctl.c | 9 +++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/man/initctl.8 b/man/initctl.8 index fbab638a..c6b283ad 100644 --- a/man/initctl.8 +++ b/man/initctl.8 @@ -11,7 +11,7 @@ .Nd Control tool for Finit .Sh SYNOPSIS .Nm /sbin/initctl -.Op Fl bcfhlpqtv +.Op Fl bcfhlpqtvV .Op COMMAND .Sh DESCRIPTION .Nm @@ -41,16 +41,20 @@ Silent, only return status of command. Skip table headings. .It Fl v, -verbose Verbose output, where applicable. +.It Fl V, -version +Show program version. .El .Sh COMMANDS .Bl -tag -width Ds .It Nm Ar debug -Toggle finit (daemon) debug to +Toggle +.Nm finit +(daemon) debug to .Pa /dev/console .It Nm Ar help Show built-in help text .It Nm Ar version -Show Finit (daemon) version +Show program version .It Nm Ar ls | list List all .Cm *.conf diff --git a/src/initctl.c b/src/initctl.c index c65c4a12..6d0c6488 100644 --- a/src/initctl.c +++ b/src/initctl.c @@ -891,12 +891,13 @@ static int usage(int rc) " -q, --quiet Silent, only return status of command\n" " -t, --no-heading Skip table headings\n" " -v, --verbose Verbose output\n" + " -R, --version Show program version\n" " -h, --help This help text\n" "\n" "Commands:\n" " debug Toggle Finit (daemon) debug\n" " help This help text\n" - " version Show Finit version\n" + " version Show program version\n" "\n", prognm); if (has_rcsd) @@ -1031,6 +1032,7 @@ int main(int argc, char *argv[]) { "quiet", 0, NULL, 'q' }, { "no-heading", 0, NULL, 't' }, { "verbose", 0, NULL, 'v' }, + { "version", 0, NULL, 'V' }, { NULL, 0, NULL, 0 } }; struct cmd cond[] = { @@ -1090,7 +1092,7 @@ int main(int argc, char *argv[]) cgrp = cgroup_avail(); utmp = has_utmp(); - while ((c = getopt_long(argc, argv, "1bcdfh?pqtv", long_options, NULL)) != EOF) { + while ((c = getopt_long(argc, argv, "1bcdfh?pqtvV", long_options, NULL)) != EOF) { switch(c) { case '1': ionce = 1; @@ -1131,6 +1133,9 @@ int main(int argc, char *argv[]) case 'v': verbose = 1; break; + + case 'V': + return show_version(NULL); } }