]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: hide first column with --plain instead of --no-legend
authorJouke Witteveen <j.witteveen@gmail.com>
Fri, 17 Apr 2020 09:40:03 +0000 (11:40 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 17 Apr 2020 17:15:49 +0000 (19:15 +0200)
Hiding the first column, which may contain bullet circles, with --no-legend
is undocumented and potentially unexpected. On the other hand, not printing
bullet circles with --plain is documented so hiding the column with that
switch is sensible.

The combination "--full --no-legend --no-pager --plain" is appropriate for
automated processing of systemctl output.

NEWS
shell-completion/bash/systemctl.in
shell-completion/bash/systemd-analyze
shell-completion/bash/systemd-cgls
shell-completion/bash/systemd-nspawn
shell-completion/bash/systemd-run
shell-completion/bash/udevadm
shell-completion/zsh/_systemctl.in
shell-completion/zsh/_systemd-run
src/systemctl/systemctl.c

diff --git a/NEWS b/NEWS
index 29e5490b9b9bc8c2e343bf7375ce548ff13e3981..4574c4555a3feb2431d5849ac4a1c3bb1fee2b0e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,10 @@ CHANGES WITH 246 in spe:
           the core file, systemd-coredump will use the effective uid and gid of
           the process that faulted.
 
+        * "systemctl list-units" and "systemctl list-machines" no longer hide
+          their first output column with --no-legend. To hide the first column,
+          use --plain.
+
 CHANGES WITH 245:
 
         * A new tool "systemd-repart" has been added, that operates as an
index f81dafba8ee4a6bd3e61789599308f7d104e078b..fdbe32e5f7aeeed3ac967c6d411c34dadfdb45b4 100644 (file)
@@ -7,7 +7,7 @@
 
 __systemctl() {
     local mode=$1; shift 1
-    systemctl $mode --full --no-legend --no-pager "$@" 2>/dev/null
+    systemctl $mode --full --no-legend --no-pager --plain "$@" 2>/dev/null
 }
 
 __systemd_properties() {
index 1b4f1b0d10403d6f9c6c11a7ce769c534de21834..0c61f54504c65341959955a2c7c48491acaae152 100644 (file)
@@ -31,7 +31,7 @@ __get_machines() {
 }
 
 __get_services() {
-    systemctl list-units --no-legend --no-pager -t service --all $1 | \
+    systemctl list-units --no-legend --no-pager --plain -t service --all $1 | \
         { while read -r a b c; do [[ $b == "loaded" ]]; echo " $a"; done }
 }
 
index 10f6b38fcc5aec569b71646d496d61ffbc1072a2..ae41f8ba5a44299379794f4e7eeabff5409dd4e6 100644 (file)
@@ -29,7 +29,7 @@ __get_machines() {
 }
 
 __get_units_have_cgroup() {
-    systemctl $1 list-units | {
+    systemctl $1 --full --no-legend --no-pager --plain list-units | {
         while read -r a b c d; do
             [[ $c == "active" && ${a##*.} =~ (service|socket|mount|swap|slice|scope) ]] && echo " $a"
         done
index d263fd5dd93b0b936fd7d9473a49ffea336a4cd6..a731167680fbf6908c7b5e6316dfb7d753114576 100644 (file)
@@ -30,7 +30,7 @@ __get_users() {
 
 __get_slices() {
     local a b
-    systemctl list-units -t slice --no-legend --no-pager | { while read a b; do echo " $a"; done; };
+    systemctl list-units -t slice --no-legend --no-pager --plain | { while read a b; do echo " $a"; done; };
 }
 
 __get_machines() {
index 71692aa19c9ac12d46b3fe5ca15f2160a62ad820..88f4443ad9727f00493404f16935a989241ce5b8 100644 (file)
@@ -18,7 +18,7 @@
 
 __systemctl() {
     local mode=$1; shift 1
-    systemctl $mode --full --no-legend "$@"
+    systemctl $mode --full --no-legend --no-pager --plain "$@"
 }
 
 __get_slice_units () { __systemctl $1 list-units --all -t slice \
index cb12c25538f1d94995fba72045b10c9d147d3b92..76126a63297c79cd21649319c3a4c79433d8def5 100644 (file)
@@ -38,7 +38,7 @@ __get_all_devs() {
 }
 
 __get_all_device_units() {
-    systemctl list-units -t device --full --no-legend --no-pager 2>/dev/null | \
+    systemctl list-units -t device --full --no-legend --no-pager --plain 2>/dev/null | \
         { while read -r a b; do echo "$a"; done; }
 }
 
index 66bf03d05876a688736ce655a95c1a10ca175bdd..c067bf8f2792ba50c5bd9b4b8ef3f62fa5c9eb9e 100644 (file)
 # @todo _systemd-run has a helper with the same name, so we must redefine
 __systemctl()
 {
-    systemctl $_sys_service_mgr --full --no-legend --no-pager "$@" 2>/dev/null
+    systemctl $_sys_service_mgr --full --no-legend --no-pager --plain "$@" 2>/dev/null
 }
 
 
index ca0faa14844dd2e3fc1224992c921361a6626e81..22b82d66fd814dcd9ad001df081f2f990e854ffa 100644 (file)
@@ -5,7 +5,7 @@
 __systemctl() {
     local -a _modes
     _modes=("--user" "--system")
-    systemctl ${words:*_modes} --full --no-legend --no-pager "$@" 2>/dev/null
+    systemctl ${words:*_modes} --full --no-legend --no-pager --plain "$@" 2>/dev/null
 }
 
 (( $+functions[__systemd-run_get_slices] )) ||
index dcd93fce17284625cc99b605e6f3d6a289d5a639..64e23f0734e0b12dc2be855dcb6a691dfaba67ed 100644 (file)
@@ -401,8 +401,8 @@ static int output_units_list(const UnitInfo *unit_infos, unsigned c) {
                 return log_oom();
 
         table_set_header(table, !arg_no_legend);
-        if (arg_no_legend) {
-                /* Hide the 'glyph' column when --no-legend is requested */
+        if (arg_plain) {
+                /* Hide the 'glyph' column when --plain is requested */
                 r = table_hide_column_from_display(table, 0);
                 if (r < 0)
                         return log_error_errno(r, "Failed to hide column: %m");
@@ -1987,8 +1987,8 @@ static int output_machines_list(struct machine_info *machine_infos, unsigned n)
                 return log_oom();
 
         table_set_header(table, !arg_no_legend);
-        if (arg_no_legend) {
-                /* Hide the 'glyph' column when --no-legend is requested */
+        if (arg_plain) {
+                /* Hide the 'glyph' column when --plain is requested */
                 r = table_hide_column_from_display(table, 0);
                 if (r < 0)
                         return log_error_errno(r, "Failed to hide column: %m");