Add $SYSTEMD_INVOKED_AS (#42286)

This commit is contained in:
Yu Watanabe
2026-05-26 02:25:08 +09:00
committed by GitHub
5 changed files with 50 additions and 27 deletions
+8 -1
View File
@@ -1,8 +1,11 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <stdlib.h>
#include "alloc-util.h"
#include "ansi-color.h"
#include "help-util.h"
#include "path-util.h"
#include "pretty-print.h"
/* These are helpers for putting together --help texts in a uniform way with a common output style. Each
@@ -25,12 +28,16 @@
* options.[ch] APIs. */
void help_cmdline(const char *arguments) {
const char *progname =
last_path_component(secure_getenv("SYSTEMD_INVOKED_AS"))
?: program_invocation_short_name;
assert(arguments);
printf("%s>%s %s %s\n",
ansi_grey(),
ansi_normal(),
program_invocation_short_name,
progname,
arguments);
}