mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
fix(shell-completion): discard error messages
This commit is contained in:
@@ -81,7 +81,7 @@ _journalctl() {
|
||||
comps=$( journalctl --output=help 2>/dev/null )
|
||||
;;
|
||||
--field|-F)
|
||||
comps=$(journalctl --fields | sort 2>/dev/null)
|
||||
comps=$(journalctl --fields 2>/dev/null | sort)
|
||||
;;
|
||||
--machine|-M)
|
||||
comps=$( __get_machines )
|
||||
|
||||
@@ -26,9 +26,9 @@ __contains_word () {
|
||||
done
|
||||
}
|
||||
|
||||
__get_all_sessions () { loginctl --no-legend list-sessions | { while read -r a b; do printf "%s\n" "$a"; done; } ; }
|
||||
__get_all_users () { loginctl --no-legend list-users | { while read -r a b; do printf "%s\n" "$b"; done; } ; }
|
||||
__get_all_seats () { loginctl --no-legend list-seats | { while read -r a b; do printf "%s\n" "$a"; done; } ; }
|
||||
__get_all_sessions () { loginctl --no-legend list-sessions 2>/dev/null | { while read -r a b; do printf "%s\n" "$a"; done; } ; }
|
||||
__get_all_users () { loginctl --no-legend list-users 2>/dev/null | { while read -r a b; do printf "%s\n" "$b"; done; } ; }
|
||||
__get_all_seats () { loginctl --no-legend list-seats 2>/dev/null | { while read -r a b; do printf "%s\n" "$a"; done; } ; }
|
||||
|
||||
__get_machines() {
|
||||
local a b
|
||||
|
||||
@@ -26,7 +26,7 @@ __contains_word () {
|
||||
}
|
||||
|
||||
__get_links() {
|
||||
networkctl list --no-legend --no-pager --all --full | { while read -r a b c; do echo " $b"; done; }
|
||||
networkctl list --no-legend --no-pager --all --full 2>/dev/null | { while read -r a b c; do echo " $b"; done; }
|
||||
}
|
||||
|
||||
__get_links_with_prefix() {
|
||||
@@ -70,7 +70,7 @@ _networkctl() {
|
||||
if __contains_word "$prev" ${OPTS[ARG]}; then
|
||||
case $prev in
|
||||
--json)
|
||||
comps=$(networkctl --json=help)
|
||||
comps=$(networkctl --json=help 2>/dev/null)
|
||||
;;
|
||||
*)
|
||||
return 0
|
||||
|
||||
@@ -67,7 +67,7 @@ _resolvectl() {
|
||||
comps=$( __get_interfaces )
|
||||
;;
|
||||
--protocol|-p|--type|-t|--class|-c|--json)
|
||||
comps=$( resolvectl --legend=no "$prev" help; echo help )
|
||||
comps=$( resolvectl --legend=no "$prev" help 2>/dev/null; echo help )
|
||||
;;
|
||||
--raw)
|
||||
comps="payload packet"
|
||||
|
||||
@@ -21,7 +21,7 @@ __systemctl() {
|
||||
systemctl --system --full --no-legend --no-pager --plain "$@"
|
||||
}
|
||||
|
||||
__get_slice_units () { __systemctl list-units --all -t slice |
|
||||
__get_slice_units () { __systemctl list-units --all -t slice 2>/dev/null |
|
||||
{ while read -r a b c d; do echo " $a"; done; }; }
|
||||
|
||||
__get_machines() {
|
||||
|
||||
@@ -13,7 +13,7 @@ __systemctl() {
|
||||
}
|
||||
|
||||
__systemd_properties() {
|
||||
{{LIBEXECDIR}}/systemd --dump-bus-properties
|
||||
{{LIBEXECDIR}}/systemd --dump-bus-properties 2>/dev/null
|
||||
}
|
||||
|
||||
__contains_word () {
|
||||
|
||||
@@ -34,18 +34,18 @@ __get_machines() {
|
||||
}
|
||||
|
||||
__get_units_all() {
|
||||
systemctl list-units --no-legend --no-pager --plain --all $1 |
|
||||
systemctl list-units --no-legend --no-pager --plain --all $1 2>/dev/null |
|
||||
{ while read -r a b c; do echo " $a"; done; }
|
||||
}
|
||||
|
||||
__get_services() {
|
||||
systemctl list-units --no-legend --no-pager --plain -t service --all $1 |
|
||||
systemctl list-units --no-legend --no-pager --plain -t service --all $1 2>/dev/null |
|
||||
{ while read -r a b c; do [[ $b == "loaded" ]] && echo " $a"; done; }
|
||||
}
|
||||
|
||||
__get_syscall_sets() {
|
||||
local line
|
||||
systemd-analyze syscall-filter --no-pager | while IFS= read -r line; do
|
||||
systemd-analyze syscall-filter --no-pager 2>/dev/null | while IFS= read -r line; do
|
||||
if [[ $line == @* ]]; then
|
||||
printf '%s\n' "$line"
|
||||
fi
|
||||
@@ -53,7 +53,7 @@ __get_syscall_sets() {
|
||||
}
|
||||
|
||||
__get_architectures() {
|
||||
systemd-analyze --no-legend --no-pager architectures | { while read -r a b; do echo " $a"; done; }
|
||||
systemd-analyze --no-legend --no-pager architectures 2>/dev/null | { while read -r a b; do echo " $a"; done; }
|
||||
}
|
||||
|
||||
_systemd_analyze() {
|
||||
|
||||
@@ -32,7 +32,7 @@ __get_machines() {
|
||||
}
|
||||
|
||||
__get_units_have_cgroup() {
|
||||
systemctl $1 --full --no-legend --no-pager --plain list-units | {
|
||||
systemctl $1 --full --no-legend --no-pager --plain list-units 2>/dev/null | {
|
||||
while read -r a b c d; do
|
||||
[[ $c == "active" && ${a##*.} =~ (service|socket|mount|swap|slice|scope) ]] && echo " $a"
|
||||
done
|
||||
|
||||
@@ -26,12 +26,14 @@ __contains_word() {
|
||||
|
||||
__get_users() {
|
||||
local a b
|
||||
loginctl list-users --no-legend --no-pager | { while read -r a b; do echo " $b"; done; }
|
||||
loginctl list-users --no-legend --no-pager 2>/dev/null |
|
||||
{ while read -r a b; do echo " $b"; done; }
|
||||
}
|
||||
|
||||
__get_slices() {
|
||||
local a b
|
||||
systemctl list-units -t slice --no-legend --no-pager --plain | { while read -r a b; do echo " $a"; done; }
|
||||
systemctl list-units -t slice --no-legend --no-pager --plain 2>/dev/null |
|
||||
{ while read -r a b; do echo " $a"; done; }
|
||||
}
|
||||
|
||||
__get_machines() {
|
||||
|
||||
@@ -26,7 +26,7 @@ __contains_word () {
|
||||
}
|
||||
|
||||
__get_names() {
|
||||
systemd-path | { while IFS=: read -r a b; do echo " $a"; done; }
|
||||
systemd-path 2>/dev/null | { while IFS=: read -r a b; do echo " $a"; done; }
|
||||
}
|
||||
|
||||
_systemd_path() {
|
||||
|
||||
@@ -50,7 +50,7 @@ _systemd-resolve() {
|
||||
comps=$( __get_interfaces )
|
||||
;;
|
||||
--protocol|-p|--type|-t|--class|-c)
|
||||
comps=$( systemd-resolve --legend=no "$prev" help; echo help )
|
||||
comps=$( systemd-resolve --legend=no "$prev" help 2>/dev/null; echo help )
|
||||
;;
|
||||
--raw)
|
||||
comps="payload packet"
|
||||
|
||||
@@ -22,7 +22,7 @@ __systemctl() {
|
||||
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 2>/dev/null |
|
||||
{ while read -r a b c d; do echo " $a"; done; }; }
|
||||
|
||||
__get_properties () {
|
||||
@@ -31,7 +31,7 @@ __get_properties () {
|
||||
}
|
||||
|
||||
__get_path_properties () {
|
||||
systemd-analyze transient-settings path |
|
||||
systemd-analyze transient-settings path 2>/dev/null |
|
||||
while read -r p; do [ -z "$p" ] || echo "$p="; done
|
||||
}
|
||||
|
||||
|
||||
@@ -28,12 +28,12 @@ __contains_word () {
|
||||
|
||||
__get_all_users () {
|
||||
local a b
|
||||
userdbctl user --no-legend -B | { while read -r a b; do printf "%s\n" "$a"; done; }
|
||||
userdbctl user --no-legend -B 2>/dev/null | { while read -r a b; do printf "%s\n" "$a"; done; }
|
||||
}
|
||||
|
||||
__get_all_groups () {
|
||||
local a b
|
||||
userdbctl group --no-legend -B | { while read -r a b; do printf "%s\n" "$a"; done; }
|
||||
userdbctl group --no-legend -B 2>/dev/null | { while read -r a b; do printf "%s\n" "$a"; done; }
|
||||
}
|
||||
|
||||
_userdbctl () {
|
||||
|
||||
@@ -17,7 +17,7 @@ _coredumpctl_commands(){
|
||||
local -a _dumps
|
||||
cmd="${${_coredumpctl_cmds[(r)$words[1]:*]%%:*}}"
|
||||
if (( $#cmd )); then
|
||||
_dumps=( "${(f)$(coredumpctl list -q --no-legend | awk 'BEGIN{OFS=":"} {sub(/[[ \t]+/, ""); print $4,$0}' 2>/dev/null)}" )
|
||||
_dumps=( "${(f)$(coredumpctl list -q --no-legend 2>/dev/null | awk 'BEGIN{OFS=":"} {sub(/[[ \t]+/, ""); print $4,$0}')}" )
|
||||
if [[ -n "$_dumps" ]]; then
|
||||
_describe -V -t pids 'coredumps' _dumps
|
||||
else
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
(( $+functions[_loginctl_all_sessions] )) ||
|
||||
_loginctl_all_sessions() {
|
||||
local session description
|
||||
loginctl --no-legend list-sessions | while read -r session description; do
|
||||
loginctl --no-legend list-sessions 2>/dev/null | while read -r session description; do
|
||||
_sys_all_sessions+=( "$session" )
|
||||
_sys_all_sessions_descr+=( "${session}:$description" )
|
||||
done
|
||||
@@ -13,7 +13,7 @@ _loginctl_all_sessions() {
|
||||
(( $+functions[_loginctl_all_users] )) ||
|
||||
_loginctl_all_users() {
|
||||
local uid description
|
||||
loginctl --no-legend list-users | while read -r uid description; do
|
||||
loginctl --no-legend list-users 2>/dev/null | while read -r uid description; do
|
||||
_sys_all_users+=( "$uid" )
|
||||
_sys_all_users_descr+=( "${uid}:$description" )
|
||||
done
|
||||
@@ -22,7 +22,7 @@ _loginctl_all_users() {
|
||||
(( $+functions[_loginctl_all_seats] )) ||
|
||||
_loginctl_all_seats() {
|
||||
local seat description
|
||||
loginctl --no-legend list-seats | while read -r seat description; do
|
||||
loginctl --no-legend list-seats 2>/dev/null | while read -r seat description; do
|
||||
_sys_all_seats+=( "$seat" )
|
||||
_sys_all_seats_descr+=( "${seat}:$description" )
|
||||
done
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
__machinectl_get_images () {
|
||||
local -a flags
|
||||
if [[ $PREFIX == .* ]]; then flags=( --all ); fi
|
||||
machinectl --no-legend list-images $flags | {while read -r a b; do
|
||||
machinectl --no-legend list-images $flags 2>/dev/null | {while read -r a b; do
|
||||
# escape : and \; do not interpret existing escape sequences
|
||||
printf -- "%s\n" ${a//(#b)(\\|:)/\\$match}
|
||||
done;}
|
||||
|
||||
@@ -19,21 +19,21 @@
|
||||
(( $+functions[_resolvectl_protocols] )) ||
|
||||
_resolvectl_protocols() {
|
||||
local -a _protocol
|
||||
_protocol=( $(_call_program protocol ${service} --legend=no --protocol help; echo help) )
|
||||
_protocol=( $(_call_program protocol ${service} --legend=no --protocol help 2>/dev/null; echo help) )
|
||||
_values 'protocol' "$_protocol[@]"
|
||||
}
|
||||
|
||||
(( $+functions[_resolvectl_types] )) ||
|
||||
_resolvectl_types() {
|
||||
local -a _type
|
||||
_type=( $(_call_program type ${service} --legend=no --type help; echo help) )
|
||||
_type=( $(_call_program type ${service} --legend=no --type help 2>/dev/null; echo help) )
|
||||
_values 'type' "$_type[@]"
|
||||
}
|
||||
|
||||
(( $+functions[_resolvectl_classes] )) ||
|
||||
_resolvectl_classes() {
|
||||
local -a _class
|
||||
_class=( $(_call_program class ${service} --legend=no --class help; echo help) )
|
||||
_class=( $(_call_program class ${service} --legend=no --class help 2>/dev/null; echo help) )
|
||||
_values 'class' "$_class[@]"
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
(( $+functions[_systemd-analyze_critical-chain] )) ||
|
||||
_systemd-analyze_critical-chain() {
|
||||
local -a _units
|
||||
systemctl list-units --no-legend --no-pager --plain --all |
|
||||
systemctl list-units --no-legend --no-pager --plain --all 2>/dev/null |
|
||||
while read -r a b c; do
|
||||
_units+=($a)
|
||||
done
|
||||
@@ -29,14 +29,14 @@
|
||||
(( $+functions[_systemd-analyze_syscall-filter] )) ||
|
||||
_systemd-analyze_syscall-filter() {
|
||||
local -a _groups
|
||||
_groups=( $(systemd-analyze --quiet --no-pager syscall-filter | grep '^@') )
|
||||
_groups=( $(systemd-analyze --quiet --no-pager syscall-filter 2>/dev/null | grep '^@') )
|
||||
_describe -t groups 'syscall groups' _groups || compadd "$@"
|
||||
}
|
||||
|
||||
(( $+functions[_systemd-analyze_filesystems] )) ||
|
||||
_systemd-analyze_filesystems() {
|
||||
local -a _groups
|
||||
_groups=( $(systemd-analyze --quiet --no-pager filesystems | grep '^@') )
|
||||
_groups=( $(systemd-analyze --quiet --no-pager filesystems 2>/dev/null | grep '^@') )
|
||||
_describe -t groups 'file system groups' _groups || compadd "$@"
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
(( $+functions[_systemd-analyze_transient-settings] )) ||
|
||||
_systemd-analyze_transient-settings() {
|
||||
local -a _types
|
||||
_types=( $(systemctl --no-pager --no-legend -t help) )
|
||||
_types=( $(systemctl --no-pager --no-legend -t help 2>/dev/null) )
|
||||
_describe -t types 'unit types' _types
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user