Add $SYSTEMD_INVOKED_AS

This allows multi-call binaries to be easily invoked with a different
name. After installation, the name is set by creating a symlink. But in
build directories, we don't create the symlinks. (There are also other
ways to achieve the same thing, e.g. zsh supports $ARGV0, and exec -a
can be used, but those are either non-portable or are more complicated
to use.)  The primary use-case for me is to test --help output for
multicall binaries.

Also reorder the help for env vars to group the more generic ones near
the top.

This was initially proposed in https://github.com/systemd/systemd/pull/24054,
but there were some comments about the implementation. I had a branch
with the patch, but I don't think I ever actually submitted it as a
pull request.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-05-25 11:07:01 +02:00
parent 4d18eac5a9
commit 58e7959988
4 changed files with 38 additions and 11 deletions

View File

@@ -35,11 +35,15 @@ All tools:
no-ops. If that's what's explicitly desired, you might consider setting
`$SYSTEMD_OFFLINE=1`.
* `$SYSTEMD_IN_INITRD` — takes a boolean. If set, overrides initrd detection.
This is useful for debugging and testing initrd-only programs in the main
system.
* `$SYSTEMD_FIRST_BOOT=0|1` — if set, assume "first boot" condition to be false
or true, instead of checking the flag file created by PID 1.
* `$SD_EVENT_PROFILE_DELAYS=1` — if set, the sd-event event loop implementation
will print latency information at runtime.
* `$SYSTEMD_INVOKED_AS=name` — override argv[0] for detection of a multicall
binary. E.g. `SYSTEMD_INVOKED_AS=systemd-udevd build/udevadm`.
* `$SYSTEMD_PROC_CMDLINE` — if set, the contents are used as the kernel command
line instead of the actual one in `/proc/cmdline`. This is useful for
@@ -76,9 +80,8 @@ All tools:
(relevant in particular for the system manager and `systemd-hostnamed`).
Must be a valid hostname (either a single label or a FQDN).
* `$SYSTEMD_IN_INITRD` — takes a boolean. If set, overrides initrd detection.
This is useful for debugging and testing initrd-only programs in the main
system.
* `$SD_EVENT_PROFILE_DELAYS=1` — if set, the sd-event event loop implementation
will print latency information at runtime.
* `$SYSTEMD_BUS_TIMEOUT=SECS` — specifies the maximum time to wait for method call
completion. If no time unit is specified, assumes seconds. The usual other units