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.
This commit is contained in:
@@ -2044,7 +2044,7 @@ static int cat_config(void) {
|
||||
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
return cat_files(NULL, files, 0);
|
||||
return cat_files(NULL, files, /* flags= */ 0);
|
||||
}
|
||||
|
||||
static int help(void) {
|
||||
|
||||
Reference in New Issue
Block a user