mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-03 01:17:45 +03:00
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:
parent
75dff0f910
commit
1cabd2d0c5
4
NEWS
4
NEWS
@ -6,6 +6,10 @@ CHANGES WITH 246 in spe:
|
|||||||
the core file, systemd-coredump will use the effective uid and gid of
|
the core file, systemd-coredump will use the effective uid and gid of
|
||||||
the process that faulted.
|
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:
|
CHANGES WITH 245:
|
||||||
|
|
||||||
* A new tool "systemd-repart" has been added, that operates as an
|
* A new tool "systemd-repart" has been added, that operates as an
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
__systemctl() {
|
__systemctl() {
|
||||||
local mode=$1; shift 1
|
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() {
|
__systemd_properties() {
|
||||||
|
@ -31,7 +31,7 @@ __get_machines() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
__get_services() {
|
__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 }
|
{ while read -r a b c; do [[ $b == "loaded" ]]; echo " $a"; done }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ __get_machines() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
__get_units_have_cgroup() {
|
__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
|
while read -r a b c d; do
|
||||||
[[ $c == "active" && ${a##*.} =~ (service|socket|mount|swap|slice|scope) ]] && echo " $a"
|
[[ $c == "active" && ${a##*.} =~ (service|socket|mount|swap|slice|scope) ]] && echo " $a"
|
||||||
done
|
done
|
||||||
|
@ -30,7 +30,7 @@ __get_users() {
|
|||||||
|
|
||||||
__get_slices() {
|
__get_slices() {
|
||||||
local a b
|
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() {
|
__get_machines() {
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
__systemctl() {
|
__systemctl() {
|
||||||
local mode=$1; shift 1
|
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 \
|
__get_slice_units () { __systemctl $1 list-units --all -t slice \
|
||||||
|
@ -38,7 +38,7 @@ __get_all_devs() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
__get_all_device_units() {
|
__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; }
|
{ while read -r a b; do echo "$a"; done; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@
|
|||||||
# @todo _systemd-run has a helper with the same name, so we must redefine
|
# @todo _systemd-run has a helper with the same name, so we must redefine
|
||||||
__systemctl()
|
__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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
__systemctl() {
|
__systemctl() {
|
||||||
local -a _modes
|
local -a _modes
|
||||||
_modes=("--user" "--system")
|
_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] )) ||
|
(( $+functions[__systemd-run_get_slices] )) ||
|
||||||
|
@ -401,8 +401,8 @@ static int output_units_list(const UnitInfo *unit_infos, unsigned c) {
|
|||||||
return log_oom();
|
return log_oom();
|
||||||
|
|
||||||
table_set_header(table, !arg_no_legend);
|
table_set_header(table, !arg_no_legend);
|
||||||
if (arg_no_legend) {
|
if (arg_plain) {
|
||||||
/* Hide the 'glyph' column when --no-legend is requested */
|
/* Hide the 'glyph' column when --plain is requested */
|
||||||
r = table_hide_column_from_display(table, 0);
|
r = table_hide_column_from_display(table, 0);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to hide column: %m");
|
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();
|
return log_oom();
|
||||||
|
|
||||||
table_set_header(table, !arg_no_legend);
|
table_set_header(table, !arg_no_legend);
|
||||||
if (arg_no_legend) {
|
if (arg_plain) {
|
||||||
/* Hide the 'glyph' column when --no-legend is requested */
|
/* Hide the 'glyph' column when --plain is requested */
|
||||||
r = table_hide_column_from_display(table, 0);
|
r = table_hide_column_from_display(table, 0);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to hide column: %m");
|
return log_error_errno(r, "Failed to hide column: %m");
|
||||||
|
Loading…
Reference in New Issue
Block a user