Improve systemd-analyze man page and bash completion (#39778)

This updates example output in systemd-analyze's man page after the
tool's output was changed in a previous commit.

Additionally bash completion is added for `systemd-analyze filesystems`
and improved for `systemd-analyze calendar`.
This commit is contained in:
Luca Boccassi
2025-11-18 22:54:01 +00:00
committed by GitHub
2 changed files with 27 additions and 4 deletions

View File

@@ -464,7 +464,7 @@ $ eog targets.svg</programlisting>
<title><command>systemd-analyze exit-status <optional><replaceable>STATUS</replaceable>...</optional></command></title>
<para>This command prints a list of exit statuses along with their "class", i.e. the source of the
definition (one of <literal>glibc</literal>, <literal>systemd</literal>, <literal>LSB</literal>, or
definition (one of <literal>libc</literal>, <literal>systemd</literal>, <literal>LSB</literal>, or
<literal>BSD</literal>), see the Process Exit Codes section in
<citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
If no additional arguments are specified, all known statuses are shown. Otherwise, only the
@@ -475,8 +475,8 @@ $ eog targets.svg</programlisting>
<programlisting>$ systemd-analyze exit-status 0 1 {63..65}
NAME STATUS CLASS
SUCCESS 0 glibc
FAILURE 1 glibc
SUCCESS 0 libc
FAILURE 1 libc
- 63 -
USAGE 64 BSD
DATAERR 65 BSD

View File

@@ -56,6 +56,15 @@ __get_architectures() {
systemd-analyze --no-legend --no-pager architectures 2>/dev/null | { while read -r a b; do echo " $a"; done; }
}
__get_filesystem_sets() {
local line
systemd-analyze filesystems --no-pager 2>/dev/null | while IFS= read -r line; do
if [[ $line == @* ]]; then
printf '%s\n' "$line"
fi
done
}
_systemd_analyze() {
local i verb comps mode
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} words cword
@@ -68,7 +77,7 @@ _systemd_analyze() {
)
local -A VERBS=(
[STANDALONE]='time blame unit-files unit-paths exit-status compare-versions calendar timestamp timespan pcrs nvpcrs srk has-tpm2 smbios11 chid image-policy'
[STANDALONE]='time blame unit-files unit-paths exit-status compare-versions timestamp timespan pcrs nvpcrs srk has-tpm2 smbios11 chid image-policy'
[CRITICAL_CHAIN]='critical-chain'
[DOT]='dot'
[DUMP]='dump'
@@ -86,6 +95,8 @@ _systemd_analyze() {
[TRANSIENT_SETTINGS]='transient-settings'
[UNIT_SHELL]='unit-shell'
[UNIT_GDB]='unit-gdb'
[FILESYSTEMS]='filesystems'
[CALENDAR]='calendar'
)
local CONFIGS='locale.conf systemd/bootchart.conf systemd/coredump.conf systemd/journald.conf
@@ -265,6 +276,18 @@ _systemd_analyze() {
else
comps=$( __get_services $mode )
fi
elif __contains_word "$verb" ${VERBS[FILESYSTEMS]}; then
if [[ $cur = -* ]]; then
comps='--help --version --no-pager'
else
comps=$( __get_filesystem_sets )
fi
elif __contains_word "$verb" ${VERBS[CALENDAR]}; then
if [[ $cur = -* ]]; then
comps='--help --version --iterations --base-time'
fi
fi
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )