systemctl: hide first column with --plain instead of --no-legend

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.
This commit is contained in:
Jouke Witteveen
2020-04-17 19:15:49 +02:00
committed by Lennart Poettering
parent 75dff0f910
commit 1cabd2d0c5
10 changed files with 16 additions and 12 deletions
+1 -1
View 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() {
+1 -1
View 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 }
}
+1 -1
View 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
+1 -1
View 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() {
+1 -1
View 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 \
+1 -1
View 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; }
}