]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journalctl: show human readable text if no namespace is found
authorLennart Poettering <lennart@poettering.net>
Thu, 11 Apr 2024 17:04:14 +0000 (19:04 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 16 Apr 2024 10:08:23 +0000 (12:08 +0200)
The common case will be that no namespaces are defined, hence by default
we'd just output "NAMESPACE" and exit, which is very confusing.

Generate a nice message instead, how many of our tools do it. Suppress
it on --quiet however.

src/journal/journalctl-misc.c

index c7a49eefea2a35e22a61c01ac10dd9bb64ce4675..9d878e8e0564b357ba46a1c9f919e3facad4540f 100644 (file)
@@ -261,9 +261,14 @@ int action_list_namespaces(void) {
                 }
         }
 
-        r = table_print_with_pager(table, arg_json_format_flags, arg_pager_flags, !arg_quiet);
-        if (r < 0)
-                return table_log_print_error(r);
+        if (table_isempty(table) && FLAGS_SET(arg_json_format_flags, JSON_FORMAT_OFF)) {
+                if (!arg_quiet)
+                        log_notice("No namespaces found.");
+        } else {
+                r = table_print_with_pager(table, arg_json_format_flags, arg_pager_flags, !arg_quiet);
+                if (r < 0)
+                        return r;
+        }
 
         return 0;
 }