]> git.ipfire.org Git - thirdparty/systemd.git/commit - man/systemd-analyze.xml
analyze/cat-config: add switch to print only "interesting" parts of config files
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 12 Oct 2023 14:33:01 +0000 (16:33 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 24 Oct 2023 13:59:34 +0000 (15:59 +0200)
commit063c8382068b4cb8661aa5a77b6c7d117d0bd117
tree6523e23b3f97d4da1b81da14c8f2086132d25644
parent80788a0bd49d9992820b37096d59a69f82e80166
analyze/cat-config: add switch to print only "interesting" parts of config files

When looking at configuration, often a user wants to suppress the comments and
just look at the parts that actually configure something, roughly equivalent to
  systemd-analyze cat-config … | rg -v '^(#|;|$)
This switch implements this natively, skipping lines that start with a comment
character or only contain whitespace.

For formats that have section headers, section headers are skipped, if only
followed by stuff that would be skipped. (The last section header is printed
when we're about to print some actual output.)

Note that the caller doesn't know if the format has headers or not. We do format
type detection in pretty-print.c. So the caller only specifies tldr=true|false, and
conf_files_cat() figures out if the format has headers and whether those should
be handled specially.

The comments that show the file name are always printed, even if all of the file
is suppressed.

This is a partial answer to the discussions in
https://github.com/systemd/systemd/pull/28919,
https://github.com/systemd/systemd/pull/29248. If the default config is shown in
config files, the user can conveniently use '--tldr' to show the relevant parts.
13 files changed:
man/systemd-analyze.xml
src/analyze/analyze-cat-config.c
src/analyze/analyze.c
src/analyze/analyze.h
src/binfmt/binfmt.c
src/machine/machinectl.c
src/network/networkctl.c
src/shared/pretty-print.c
src/shared/pretty-print.h
src/sysctl/sysctl.c
src/systemctl/systemctl-edit.c
src/sysusers/sysusers.c
test/units/testsuite-65.sh