From: Eisuke Kawashima Date: Mon, 14 Jul 2025 07:06:08 +0000 (+0900) Subject: fix(shell-completion): discard error messages X-Git-Tag: v258-rc1~57^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F38210%2Fhead;p=thirdparty%2Fsystemd.git fix(shell-completion): discard error messages --- diff --git a/shell-completion/bash/journalctl b/shell-completion/bash/journalctl index 31e8e0d935b..be0239ea659 100644 --- a/shell-completion/bash/journalctl +++ b/shell-completion/bash/journalctl @@ -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 ) diff --git a/shell-completion/bash/loginctl b/shell-completion/bash/loginctl index f0e1196e615..d38221b6770 100644 --- a/shell-completion/bash/loginctl +++ b/shell-completion/bash/loginctl @@ -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 diff --git a/shell-completion/bash/networkctl b/shell-completion/bash/networkctl index 41f1b573cc9..c16768079e3 100644 --- a/shell-completion/bash/networkctl +++ b/shell-completion/bash/networkctl @@ -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 diff --git a/shell-completion/bash/resolvectl b/shell-completion/bash/resolvectl index b561a72301a..9a3c25c9902 100644 --- a/shell-completion/bash/resolvectl +++ b/shell-completion/bash/resolvectl @@ -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" diff --git a/shell-completion/bash/run0 b/shell-completion/bash/run0 index fe2efedd309..0850b6ef962 100644 --- a/shell-completion/bash/run0 +++ b/shell-completion/bash/run0 @@ -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() { diff --git a/shell-completion/bash/systemctl.in b/shell-completion/bash/systemctl.in index 1004ac60431..cbca727ceec 100644 --- a/shell-completion/bash/systemctl.in +++ b/shell-completion/bash/systemctl.in @@ -13,7 +13,7 @@ __systemctl() { } __systemd_properties() { - {{LIBEXECDIR}}/systemd --dump-bus-properties + {{LIBEXECDIR}}/systemd --dump-bus-properties 2>/dev/null } __contains_word () { diff --git a/shell-completion/bash/systemd-analyze b/shell-completion/bash/systemd-analyze index 24478dd3bf8..8329b1b495b 100644 --- a/shell-completion/bash/systemd-analyze +++ b/shell-completion/bash/systemd-analyze @@ -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() { diff --git a/shell-completion/bash/systemd-cgls b/shell-completion/bash/systemd-cgls index 2ec843f0464..aa30e7082e9 100644 --- a/shell-completion/bash/systemd-cgls +++ b/shell-completion/bash/systemd-cgls @@ -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 diff --git a/shell-completion/bash/systemd-nspawn b/shell-completion/bash/systemd-nspawn index 49164fb90c3..574018b1fff 100644 --- a/shell-completion/bash/systemd-nspawn +++ b/shell-completion/bash/systemd-nspawn @@ -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() { diff --git a/shell-completion/bash/systemd-path b/shell-completion/bash/systemd-path index 59d6597d06b..2b62a0d9854 100644 --- a/shell-completion/bash/systemd-path +++ b/shell-completion/bash/systemd-path @@ -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() { diff --git a/shell-completion/bash/systemd-resolve b/shell-completion/bash/systemd-resolve index 17890a9a094..791c0f541f9 100644 --- a/shell-completion/bash/systemd-resolve +++ b/shell-completion/bash/systemd-resolve @@ -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" diff --git a/shell-completion/bash/systemd-run b/shell-completion/bash/systemd-run index e1a14ff2b05..ba8f84b513b 100644 --- a/shell-completion/bash/systemd-run +++ b/shell-completion/bash/systemd-run @@ -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 } diff --git a/shell-completion/bash/userdbctl b/shell-completion/bash/userdbctl index b068fe81fdb..514487f2e78 100644 --- a/shell-completion/bash/userdbctl +++ b/shell-completion/bash/userdbctl @@ -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 () { diff --git a/shell-completion/zsh/_coredumpctl b/shell-completion/zsh/_coredumpctl index 74726260695..b288e0895f2 100644 --- a/shell-completion/zsh/_coredumpctl +++ b/shell-completion/zsh/_coredumpctl @@ -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 diff --git a/shell-completion/zsh/_loginctl b/shell-completion/zsh/_loginctl index 3a98d01c0e6..6b74ccdd609 100644 --- a/shell-completion/zsh/_loginctl +++ b/shell-completion/zsh/_loginctl @@ -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 diff --git a/shell-completion/zsh/_machinectl b/shell-completion/zsh/_machinectl index 99cc103755e..d5f7aa9680d 100644 --- a/shell-completion/zsh/_machinectl +++ b/shell-completion/zsh/_machinectl @@ -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;} diff --git a/shell-completion/zsh/_resolvectl b/shell-completion/zsh/_resolvectl index 2917138fff3..3d28f1b410e 100644 --- a/shell-completion/zsh/_resolvectl +++ b/shell-completion/zsh/_resolvectl @@ -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[@]" } diff --git a/shell-completion/zsh/_systemd-analyze b/shell-completion/zsh/_systemd-analyze index 39984440ea8..dfbc70d138c 100644 --- a/shell-completion/zsh/_systemd-analyze +++ b/shell-completion/zsh/_systemd-analyze @@ -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 }