From: Lennart Poettering Date: Thu, 15 Jun 2023 08:40:31 +0000 (+0200) Subject: systemctl: let's emphasize a bit that halt/poweroff/reboot/shutdown are compat commands X-Git-Tag: v254-rc1~196 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6e89663d23230bef4ddcbb0a80bfdf6daa714887;p=thirdparty%2Fsystemd.git systemctl: let's emphasize a bit that halt/poweroff/reboot/shutdown are compat commands Let's try to make clear that these calls really should not be extended anymore, but remain as the compat glue they are but not more. Anything new should really be added to systemctl poweroff/halt/reboot, which is actually defined and owned by us. This is added in light of a9c3cc8db02dc36d41b17d0bbf1e02500046e4ce which really shouldn't have been added I am sure. This adds two things: a note to the --help text that people use the relevant systemctl commands instead (as they are a lot more powerful, for example give you inhibitor and boot loader control, kexec, and so on). And a note to developers that they stop adding new stuff to the compat interfaces. --- diff --git a/src/systemctl/systemctl-compat-halt.c b/src/systemctl/systemctl-compat-halt.c index b9164c27abd..4f6e3048167 100644 --- a/src/systemctl/systemctl-compat-halt.c +++ b/src/systemctl/systemctl-compat-halt.c @@ -26,6 +26,11 @@ static int halt_help(void) { if (r < 0) return log_oom(); + /* Note: if you are tempted to add new command line switches here, please do not. Let this + * compatibility command rest in peace. Its interface is not even owned by us as much as it is by + * sysvinit. If you add something new, add it to "systemctl halt", "systemctl reboot", "systemctl + * poweroff" instead. */ + printf("%s [OPTIONS...]%s\n" "\n%s%s the system.%s\n" "\nOptions:\n" @@ -37,14 +42,16 @@ static int halt_help(void) { " -w --wtmp-only Don't halt/power-off/reboot, just write wtmp record\n" " -d --no-wtmp Don't write wtmp record\n" " --no-wall Don't send wall message before halt/power-off/reboot\n" + "\n%sThis is a compatibility interface, please use the more powerful 'systemctl %s' command instead.%s\n" "\nSee the %s for details.\n", program_invocation_short_name, arg_action == ACTION_REBOOT ? " [ARG]" : "", - ansi_highlight(), - arg_action == ACTION_REBOOT ? "Reboot" : - arg_action == ACTION_POWEROFF ? "Power off" : - "Halt", - ansi_normal(), + ansi_highlight(), arg_action == ACTION_REBOOT ? "Reboot" : + arg_action == ACTION_POWEROFF ? "Power off" : + "Halt", ansi_normal(), + ansi_highlight_red(), arg_action == ACTION_REBOOT ? "reboot" : + arg_action == ACTION_POWEROFF ? "poweroff" : + "halt", ansi_normal(), link); return 0; diff --git a/src/systemctl/systemctl-compat-shutdown.c b/src/systemctl/systemctl-compat-shutdown.c index 9d39e362eae..881d00e0a42 100644 --- a/src/systemctl/systemctl-compat-shutdown.c +++ b/src/systemctl/systemctl-compat-shutdown.c @@ -18,6 +18,11 @@ static int shutdown_help(void) { if (r < 0) return log_oom(); + /* Note: if you are tempted to add new command line switches here, please do not. Let this + * compatibility command rest in peace. Its interface is not even owned by us as much as it is by + * sysvinit. If you add something new, add it to "systemctl halt", "systemctl reboot", "systemctl + * poweroff" instead. */ + printf("%s [OPTIONS...] [TIME] [WALL...]\n" "\n%sShut down the system.%s\n" "\nOptions:\n" @@ -30,10 +35,12 @@ static int shutdown_help(void) { " --no-wall Don't send wall message before halt/power-off/reboot\n" " -c Cancel a pending shutdown\n" " --show Show pending shutdown\n" + "\n%sThis is a compatibility interface, please use the more powerful 'systemctl reboot',\n" + "'systemctl poweroff', 'systemctl reboot' commands instead.%s\n" "\nSee the %s for details.\n", program_invocation_short_name, - ansi_highlight(), - ansi_normal(), + ansi_highlight(), ansi_normal(), + ansi_highlight_red(), ansi_normal(), link); return 0;