1
0
mirror of https://github.com/systemd/systemd synced 2025-10-06 20:24:45 +02:00

Compare commits

...

11 Commits

Author SHA1 Message Date
Luca Boccassi
5b94f463f0
shell-completion: prettify and discard error messages (#38210)
followup of #38182
2025-07-15 09:30:30 +01:00
Eisuke Kawashima
c2b0f637c2
fix(shell-completion): discard error messages 2025-07-14 20:24:26 +09:00
Eisuke Kawashima
86fff7fb38
fix(shell-completion): strictly parse env output
shell functions may be exported, when env prints their body in multiple
lines
2025-07-14 20:24:26 +09:00
Eisuke Kawashima
b371e7252c
fix(SC2164): robust cd conditional 2025-07-14 20:24:26 +09:00
Eisuke Kawashima
01e769bc2e
fix(SC2162): add -r to read 2025-07-14 20:24:26 +09:00
Eisuke Kawashima
cb2e0dc4f5
fix(shell-completion): correct conditional 2025-07-14 20:24:26 +09:00
Eisuke Kawashima
12e64a4848
style(shell-completion): remove unnecessary backslashes 2025-07-14 20:24:25 +09:00
Eisuke Kawashima
5300aa7a1d
style(shell-completion): remove trailing semicolons 2025-07-14 20:24:25 +09:00
Eisuke Kawashima
56c093004c
style(shell-completion): add missing semicolons 2025-07-14 20:24:25 +09:00
Eisuke Kawashima
dfe6b3fa38
style(shell-completion): expand hard tabs and fix indentation 2025-07-14 20:24:25 +09:00
Eisuke Kawashima
2da41c4b51
fix(shell-completion): fix help string 2025-07-14 20:24:25 +09:00
43 changed files with 307 additions and 303 deletions

View File

@ -25,7 +25,7 @@ __contains_word () {
}
__get_entry_ids() {
bootctl --no-pager list 2>/dev/null | { while read -r a b; do [[ $a == 'id:' ]] && echo " $b"; done }
bootctl --no-pager list 2>/dev/null | { while read -r a b; do [[ $a == 'id:' ]] && echo " $b"; done; }
}
_bootctl() {
@ -94,7 +94,7 @@ _bootctl() {
if ! __contains_word "${COMP_WORDS[i]}" ${OPTS[*]} ${VERBS[*]} &&
! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
name=${COMP_WORDS[i]}
break;
break
fi
done

View File

@ -26,8 +26,8 @@ __contains_word () {
__get_machines() {
local a b
{ machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null; echo ".host"; } | \
{ while read a b; do echo " $a"; done; } | \
{ machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null; echo ".host"; } |
{ while read -r a b; do echo " $a"; done; } |
sort -u
}
@ -35,7 +35,7 @@ __get_busnames() {
local mode=$1
local a b
busctl $mode list --no-legend --no-pager --full 2>/dev/null |
{ while read a b; do echo " $a"; done; };
{ while read -r a b; do echo " $a"; done; }
}
__get_objects() {
@ -43,7 +43,7 @@ __get_objects() {
local busname=$2
local a b
busctl $mode tree --list --no-legend --no-pager $busname 2>/dev/null |
{ while read a b; do echo " $a"; done; };
{ while read -r a b; do echo " $a"; done; }
}
__get_interfaces() {
@ -52,7 +52,7 @@ __get_interfaces() {
local path=$3
local a b c
busctl $mode introspect --list --no-legend --no-pager $busname $path 2>/dev/null |
{ while read a b c; do [[ "$b" == "interface" ]] && echo " $a"; done; };
{ while read -r a b c; do [[ "$b" == "interface" ]] && echo " $a"; done; }
}
__get_members() {
@ -65,7 +65,7 @@ __get_members() {
local a b c d e
busctl $mode introspect --list --no-legend --no-pager $busname $path $interface 2>/dev/null |
sed -e 's/^\.//' |
{ while read a b c d e; do [[ "$b" == "$type" && ( -z $flags || "$e" == "$flags" ) ]] && echo " $a"; done; };
{ while read -r a b c d e; do [[ "$b" == "$type" && ( -z $flags || "$e" == "$flags" ) ]] && echo " $a"; done; }
}
__get_signature() {
@ -76,7 +76,7 @@ __get_signature() {
local member=$5
local a b c d
busctl $mode introspect --list --no-legend --no-pager $busname $path $interface 2>/dev/null |
sed -e 's/^\.//' | { while read a b c d; do [[ "$a" == "$member" && "$c" != '-' ]] && echo " \"$c\""; done; };
sed -e 's/^\.//' | { while read -r a b c d; do [[ "$a" == "$member" && "$c" != '-' ]] && echo " \"$c\""; done; }
}
_busctl() {

View File

@ -27,7 +27,7 @@ __contains_word () {
__get_machines() {
local a b
machinectl list --full --no-legend --no-pager 2>/dev/null |
{ while read a b; do echo " $a"; done; };
{ while read -r a b; do echo " $a"; done; }
}
__get_homes() {

View File

@ -29,7 +29,7 @@ __contains_word () {
__get_machines() {
local a b
machinectl list --full --no-legend --no-pager 2>/dev/null |
{ while read a b; do echo " $a"; done; };
{ while read -r a b; do echo " $a"; done; }
}
_hostnamectl() {

View File

@ -26,8 +26,12 @@ __contains_word() {
__get_machines() {
local a b
{ machinectl list-images --full --no-legend --no-pager 2>/dev/null; machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null; echo ".host"; } | \
{ while read a b; do echo " $a"; done; } | \
{
machinectl list-images --full --no-legend --no-pager 2>/dev/null
machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null
echo ".host"
} |
{ while read -r a b; do echo " $a"; done; } |
sort -u
}

View File

@ -28,8 +28,8 @@ __contains_word () {
__get_machines() {
local a b
{ machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null; echo ".host"; } | \
{ while read a b; do echo " $a"; done; } | \
{ machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null; echo ".host"; } |
{ while read -r a b; do echo " $a"; done; } |
sort -u
}
@ -61,7 +61,7 @@ _journalctl() {
if __contains_word "$prev" '>' '>>' '&>'; then
compopt -o filenames
COMPREPLY=( $(compgen -f -- "$cur") )
return 0;
return 0
fi
if __contains_word "$prev" ${OPTS[ARG]} ${OPTS[ARGUNKNOWN]}; then
@ -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 )

View File

@ -36,11 +36,11 @@ _kernel_install() {
comps="add remove"
;;
2)
comps=$(cd /lib/modules; echo [0-9]*)
comps=$(cd /lib/modules && echo [0-9]*)
if [[ ${COMP_WORDS[1]} == "remove" ]] && [[ -f /etc/machine-id ]]; then
read MACHINE_ID < /etc/machine-id
read -r MACHINE_ID < /etc/machine-id
if [[ $MACHINE_ID ]] && ( [[ -d /boot/$MACHINE_ID ]] || [[ -L /boot/$MACHINE_ID ]] ); then
comps=$(cd "/boot/$MACHINE_ID"; echo [0-9]*)
comps=$(cd "/boot/$MACHINE_ID" && echo [0-9]*)
fi
fi
;;

View File

@ -26,14 +26,14 @@ __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
{ machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null; echo ".host"; } | \
{ while read a b; do echo " $a"; done; } | \
{ machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null; echo ".host"; } |
{ while read -r a b; do echo " $a"; done; } |
sort -u
}

View File

@ -26,8 +26,8 @@ __contains_word() {
__get_machines() {
local a b
{ machinectl list-images --full --no-legend --no-pager 2>/dev/null; machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null; echo ".host"; } | \
{ while read a b; do echo " $a"; done; } | \
{ machinectl list-images --full --no-legend --no-pager 2>/dev/null; machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null; echo ".host"; } |
{ while read -r a b; do echo " $a"; done; } |
sort -u
}

View File

@ -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

View File

@ -26,8 +26,8 @@ __contains_word () {
__get_machines() {
local a b
{ machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null; echo ".host"; } | \
{ while read a b; do echo " $a"; done; } | \
{ machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null; echo ".host"; } |
{ while read -r a b; do echo " $a"; done; } |
sort -u
}

View File

@ -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"
@ -107,7 +107,7 @@ _resolvectl() {
if __contains_word "${COMP_WORDS[i]}" ${ARGS[FAMILY]} &&
! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
name=${COMP_WORDS[i]}
break;
break
fi
done
if [[ -z $name ]]; then
@ -122,7 +122,7 @@ _resolvectl() {
if __contains_word "${COMP_WORDS[i]}" $interfaces &&
! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
name=${COMP_WORDS[i]}
break;
break
fi
done
@ -135,7 +135,7 @@ _resolvectl() {
if __contains_word "${COMP_WORDS[i]}" ${ARGS[RESOLVE]} &&
! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
name=${COMP_WORDS[i]}
break;
break
fi
done
@ -151,7 +151,7 @@ _resolvectl() {
if __contains_word "${COMP_WORDS[i]}" ${ARGS[BOOLEAN]} &&
! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
name=${COMP_WORDS[i]}
break;
break
fi
done
@ -167,7 +167,7 @@ _resolvectl() {
if __contains_word "${COMP_WORDS[i]}" ${ARGS[DNSSEC]} &&
! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
name=${COMP_WORDS[i]}
break;
break
fi
done
@ -183,7 +183,7 @@ _resolvectl() {
if __contains_word "${COMP_WORDS[i]}" ${ARGS[DNSOVERTLS]} &&
! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
name=${COMP_WORDS[i]}
break;
break
fi
done

View File

@ -21,13 +21,13 @@ __systemctl() {
systemctl --system --full --no-legend --no-pager --plain "$@"
}
__get_slice_units () { __systemctl list-units --all -t slice \
| { while read -r a b c d; do echo " $a"; done; }; }
__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() {
local a b
{ machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null; echo ".host"; } | \
{ while read a b; do echo " $a"; done; } | \
{ machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null; echo ".host"; } |
{ while read -r a b; do echo " $a"; done; } |
sort -u
}

View File

@ -13,7 +13,7 @@ __systemctl() {
}
__systemd_properties() {
{{LIBEXECDIR}}/systemd --dump-bus-properties
{{LIBEXECDIR}}/systemd --dump-bus-properties 2>/dev/null
}
__contains_word () {
@ -55,20 +55,20 @@ __filter_units_by_properties () {
}
{% endraw %}
__get_all_units () { { __systemctl $1 list-unit-files "$2*"; __systemctl $1 list-units --all "$2*"; } \
| { while read -r a b; do echo " $a"; done; }; }
__get_non_template_units() { { __systemctl $1 list-unit-files "$2*"; __systemctl $1 list-units --all "$2*"; } \
| { while read -r a b; do [[ $a =~ @\. ]] || echo " $a"; done; }; }
__get_template_names () { __systemctl $1 list-unit-files "$2*" \
| { while read -r a b; do [[ $a =~ @\. ]] && echo " ${a%%@.*}@"; done; }; }
__get_active_units () { __systemctl $1 list-units "$2*" \
| { while read -r a b; do echo " $a"; done; }; }
__get_active_services() { __systemctl $1 list-units "$2*.service" \
| { while read -r a b; do echo " $a"; done; }; }
__get_all_units () { { __systemctl $1 list-unit-files "$2*"; __systemctl $1 list-units --all "$2*"; } |
{ while read -r a b; do echo " $a"; done; }; }
__get_non_template_units() { { __systemctl $1 list-unit-files "$2*"; __systemctl $1 list-units --all "$2*"; } |
{ while read -r a b; do [[ $a =~ @\. ]] || echo " $a"; done; }; }
__get_template_names () { __systemctl $1 list-unit-files "$2*" |
{ while read -r a b; do [[ $a =~ @\. ]] && echo " ${a%%@.*}@"; done; }; }
__get_active_units () { __systemctl $1 list-units "$2*" |
{ while read -r a b; do echo " $a"; done; }; }
__get_active_services() { __systemctl $1 list-units "$2*.service" |
{ while read -r a b; do echo " $a"; done; }; }
__get_not_masked_unit_files() {
# filter out masked, not-found, or template units.
__systemctl $1 list-unit-files --state enabled,enabled-runtime,linked,linked-runtime,static,indirect,disabled,generated,transient "$2*" | \
__systemctl $1 list-unit-files --state enabled,enabled-runtime,linked,linked-runtime,static,indirect,disabled,generated,transient "$2*" |
{ while read -r a b; do [[ $a =~ @\. ]] || echo " $a"; done; }
}
@ -76,7 +76,7 @@ __get_startable_units () {
__filter_units_by_properties $1 ActiveState=inactive,CanStart=yes $(
{ __get_not_masked_unit_files $1 $2
# get inactive template units
__systemctl $1 list-units --state inactive,failed "$2*" | \
__systemctl $1 list-units --state inactive,failed "$2*" |
{ while read -r a b c; do [[ $b == "loaded" ]] && echo " $a"; done; }
} | sort -u )
}
@ -107,20 +107,20 @@ __get_reloadable_units () {
} | sort -u )
}
__get_failed_units() { __systemctl $1 list-units "$2*" \
| while read -r a b c d; do [[ $c == "failed" ]] && echo " $a"; done; }
__get_enabled_units() { __systemctl $1 list-unit-files "$2*" \
| while read -r a b c ; do [[ $b == "enabled" ]] && echo " $a"; done; }
__get_disabled_units() { __systemctl $1 list-unit-files "$2*" \
| while read -r a b c ; do [[ $b == "disabled" ]] && echo " $a"; done; }
__get_masked_units() { __systemctl $1 list-unit-files "$2*" \
| while read -r a b c ; do [[ $b == "masked" ]] && echo " $a"; done; }
__get_failed_units() { __systemctl $1 list-units "$2*" |
while read -r a b c d; do [[ $c == "failed" ]] && echo " $a"; done; }
__get_enabled_units() { __systemctl $1 list-unit-files "$2*" |
while read -r a b c ; do [[ $b == "enabled" ]] && echo " $a"; done; }
__get_disabled_units() { __systemctl $1 list-unit-files "$2*" |
while read -r a b c ; do [[ $b == "disabled" ]] && echo " $a"; done; }
__get_masked_units() { __systemctl $1 list-unit-files "$2*" |
while read -r a b c ; do [[ $b == "masked" ]] && echo " $a"; done; }
__get_all_unit_files() { __systemctl $1 list-unit-files "$2*" | while read -r a b; do echo " $a"; done; }
__get_machines() {
local a
while read a _; do
while read -r a _; do
echo " $a"
done < <(machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null | sort -u; echo ".host")
}
@ -291,13 +291,13 @@ _systemctl () {
compopt -o filenames
elif __contains_word "$verb" ${VERBS[DISABLED_UNITS]}; then
comps=$( __get_disabled_units $mode "$cur";
comps=$( __get_disabled_units $mode "$cur"
__get_template_names $mode "$cur")
compopt -o filenames
elif __contains_word "$verb" ${VERBS[REENABLABLE_UNITS]}; then
comps=$( __get_disabled_units $mode "$cur";
__get_enabled_units $mode "$cur";
comps=$( __get_disabled_units $mode "$cur"
__get_enabled_units $mode "$cur"
__get_template_names $mode "$cur")
compopt -o filenames
@ -331,10 +331,10 @@ _systemctl () {
compopt -o filenames
elif __contains_word "$verb" ${VERBS[TARGET_AND_UNITS]}; then
if __contains_word "$prev" ${VERBS[TARGET_AND_UNITS]} \
|| __contains_word "$prev" ${OPTS[STANDALONE]}; then
comps=$( __systemctl $mode list-unit-files --type target --all "$cur*" \
| { while read -r a b; do echo " $a"; done; } )
if __contains_word "$prev" ${VERBS[TARGET_AND_UNITS]} ||
__contains_word "$prev" ${OPTS[STANDALONE]}; then
comps=$( __systemctl $mode list-unit-files --type target --all "$cur*" |
{ while read -r a b; do echo " $a"; done; } )
else
comps=$( __get_all_unit_files $mode "$cur" )
fi
@ -347,13 +347,13 @@ _systemctl () {
comps=$( __systemctl $mode list-jobs | { while read -r a b; do echo " $a"; done; } )
elif [ "$verb" = 'unset-environment' ]; then
comps=$( __systemctl $mode show-environment \
| while read -r line; do echo " ${line%%=*}"; done )
comps=$( __systemctl $mode show-environment |
while read -r line; do echo " ${line%%=*}"; done )
compopt -o nospace
elif [ "$verb" = 'set-environment' ]; then
comps=$( __systemctl $mode show-environment \
| while read -r line; do echo " ${line%%=*}="; done )
comps=$( __systemctl $mode show-environment |
while read -r line; do echo " ${line%%=*}="; done )
compopt -o nospace
elif [ "$verb" = 'import-environment' ]; then
@ -365,8 +365,8 @@ _systemctl () {
compopt -o filenames
elif __contains_word "$verb" ${VERBS[TARGETS]}; then
comps=$( __systemctl $mode list-unit-files --type target --full --all "$cur*" \
| { while read -r a b; do echo " $a"; done; } )
comps=$( __systemctl $mode list-unit-files --type target --full --all "$cur*" |
{ while read -r a b; do echo " $a"; done; } )
elif __contains_word "$verb" ${VERBS[LOG_LEVEL]}; then
comps='debug info notice warning err crit alert emerg'
elif __contains_word "$verb" ${VERBS[LOG_TARGET]}; then

View File

@ -28,24 +28,24 @@ __contains_word () {
__get_machines() {
local a b
{ machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null; echo ".host"; } | \
{ while read a b; do echo " $a"; done; } | \
{ machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null; echo ".host"; } |
{ while read -r a b; do echo " $a"; done; } |
sort -u
}
__get_units_all() {
systemctl list-units --no-legend --no-pager --plain --all $1 | \
{ while read -r a b c; do echo " $a"; done }
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 | \
{ while read -r a b c; do [[ $b == "loaded" ]]; echo " $a"; done }
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() {
@ -163,7 +163,7 @@ _systemd_analyze() {
if [[ $cur = -* ]]; then
comps='--help --version --system --user --global --man=no --generators=yes --root --image --recursive-errors=no --recursive-errors=yes --recursive-errors=one'
else
comps=$( compgen -A file -- "$cur";
comps=$( compgen -A file -- "$cur"
__get_units_all $mode )
compopt -o filenames
fi

View File

@ -26,17 +26,17 @@ __contains_word() {
__get_machines() {
local a b
{ machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null; echo ".host"; } | \
{ while read a b; do echo " $a"; done; } | \
{ machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null; echo ".host"; } |
{ while read -r a b; do echo " $a"; done; } |
sort -u
}
__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
};
}
}
_systemd_cgls() {

View File

@ -26,8 +26,8 @@ __contains_word() {
__get_machines() {
local a b
{ machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null; echo ".host"; } | \
{ while read a b; do echo " $a"; done; } | \
{ machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null; echo ".host"; } |
{ while read -r a b; do echo " $a"; done; } |
sort -u
}

View File

@ -26,15 +26,15 @@ __contains_word() {
__get_tpm2_devices() {
local a b c
systemd-creds --no-legend --quiet --tpm2-device=list 2>/dev/null | \
{ while read -r a b c; do echo " $a"; done }
systemd-creds --no-legend --quiet --tpm2-device=list 2>/dev/null |
{ while read -r a b c; do echo " $a"; done; }
}
__get_creds() {
local a b c
local mode=$1; shift 1
systemd-creds list $mode --no-legend --no-pager $1 2>/dev/null | \
{ while read -r a b c; do echo " $a"; done }
systemd-creds list $mode --no-legend --no-pager $1 2>/dev/null |
{ while read -r a b c; do echo " $a"; done; }
}
_systemd_creds() {

View File

@ -26,24 +26,26 @@ __contains_word() {
__get_users() {
local a b
loginctl list-users --no-legend --no-pager | { while read 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 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() {
local a b
{ machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null; echo ".host"; } | \
{ while read a b; do echo " $a"; done; } | \
{ machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null; echo ".host"; } |
{ while read -r a b; do echo " $a"; done; } |
sort -u
}
__get_env() {
local a
env | { while read a; do echo " ${a%%=*}"; done; };
env | { while read -r a; do [[ $a =~ ^[A-Za-z0-9_]+= ]] && echo " ${a%%=*}"; done; }
}
__get_interfaces(){

View File

@ -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() {

View File

@ -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"

View File

@ -22,8 +22,8 @@ __systemctl() {
systemctl $mode --full --no-legend --no-pager --plain "$@"
}
__get_slice_units () { __systemctl $1 list-units --all -t slice \
| { while read -r a b c d; do echo " $a"; done; }; }
__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 () {
systemd-analyze transient-settings scope service 2>/dev/null |
@ -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
}
@ -47,8 +47,8 @@ __get_timer_properties () {
__get_machines() {
local a b
{ machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null; echo ".host"; } | \
{ while read -r a b; do echo " $a"; done; } | \
{ machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null; echo ".host"; } |
{ while read -r a b; do echo " $a"; done; } |
sort -u
}

View File

@ -28,8 +28,8 @@ __contains_word () {
__get_machines() {
local a b
{ machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null; echo ".host"; } | \
{ while read a b; do echo " $a"; done; } | \
{ machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null; echo ".host"; } |
{ while read -r a b; do echo " $a"; done; } |
sort -u
}

View File

@ -36,7 +36,7 @@ __get_all_device_nodes() {
}
__get_all_device_units() {
systemctl list-units -t device --full --no-legend --no-pager --plain 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; }
}

View File

@ -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 () {

View File

@ -8,7 +8,7 @@ __bootctl() {
_bootctl_comp_ids() {
local expl
local -a ids
__bootctl list | while read a b; do
__bootctl list | while read -r a b; do
if [[ "$a" == "id:" ]]; then
ids+="$b"
fi

View File

@ -87,7 +87,7 @@ __dbus_matchspec() {
local -a bus_names
local NAME OTHER
__busctl --unique list |
while read NAME OTHER; do
while read -r NAME OTHER; do
echo $NAME
done
}
@ -104,7 +104,7 @@ __dbus_matchspec() {
{
local NAME TYPE OTHER
__busctl introspect "$1" "$2" |
while read NAME TYPE OTHER; do
while read -r NAME TYPE OTHER; do
if [[ ${TYPE} == "interface" ]]; then
echo ${NAME}
fi
@ -117,7 +117,7 @@ __dbus_matchspec() {
local required="$5"
local NAME TYPE SIGNATURE VALUE FLAGS
__busctl introspect "$1" "$2" "$3" |
while read NAME TYPE SIGNATURE VALUE FLAGS; do
while read -r NAME TYPE SIGNATURE VALUE FLAGS; do
[[ -z "$member" || ${TYPE} == "$member" ]] &&
[[ -z "$required" || "${${(os: :)FLAGS}}" == $~required ]] &&
echo ${NAME#.}
@ -128,7 +128,7 @@ __dbus_matchspec() {
{
local NAME TYPE SIGNATURE VALUE FLAGS
__busctl introspect "$1" "$2" "$3" |
while read NAME TYPE SIGNATURE VALUE FLAGS; do
while read -r NAME TYPE SIGNATURE VALUE FLAGS; do
if [[ ${NAME#.} == "$4" ]]; then
[[ ${SIGNATURE} != "-" ]] && echo ${SIGNATURE}
fi

View File

@ -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

View File

@ -12,7 +12,7 @@ _kernel-install_images(){
(( $+functions[_kernel-install_kernels] )) ||
_kernel-install_kernels(){
read _MACHINE_ID < /etc/machine-id
read -r _MACHINE_ID < /etc/machine-id
_kernel=( /lib/modules/[0-9]* )
if [[ "$cmd" == "remove" && -n "$_MACHINE_ID" ]]; then
_kernel=( "/boot/$_MACHINE_ID"/[0-9]* )

View File

@ -4,9 +4,9 @@
(( $+functions[_localectl_set-locale] )) ||
_localectl_set-locale() {
local -a _locales locale_fields
locale_fields=(LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME \
LC_COLLATE LC_MONETARY LC_MESSAGES LC_PAPER \
LC_NAME LC_ADDRESS LC_TELEPHONE \
locale_fields=(LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME
LC_COLLATE LC_MONETARY LC_MESSAGES LC_PAPER
LC_NAME LC_ADDRESS LC_TELEPHONE
LC_MEASUREMENT LC_IDENTIFICATION)
# LC_ALL is omitted on purpose

View File

@ -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

View File

@ -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;}

View File

@ -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[@]"
}
@ -68,7 +68,7 @@
if (( CURRENT == 1 )); then
_describe -t commands 'resolvectl commands' _resolvectl_cmds
fi
}
}
_arguments \
'(- *)'{-h,--help}'[Print a short help text and exit]' \

View File

@ -3,9 +3,8 @@
(( $+functions[__sd_machines_get_machines] )) ||
__sd_machines_get_machines () {
{ machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null; echo ".host"; } | \
{ while read a b; do echo "$a"; done; } | \
{ machinectl list --full --max-addresses=0 --no-legend --no-pager 2>/dev/null; echo ".host"; } |
{ while read -r a b; do echo "$a"; done; } |
sort -u
}

View File

@ -119,8 +119,8 @@
while _tags; do
for i in $groups; do
if _requested ${i//_/-}-commands; then
_describe -t ${i//_/-}-commands "${i//_/ } command" ${i}_commands \
&& ret=0
_describe -t ${i//_/-}-commands "${i//_/ } command" ${i}_commands &&
ret=0
fi
done
done
@ -162,7 +162,7 @@ __systemctl()
(( $+functions[_systemctl_all_units] )) ||
_systemctl_all_units()
{
if _cache_invalid SYS_ALL_UNITS$_sys_service_mgr || ! _retrieve_cache SYS_ALL_UNITS$_sys_service_mgr;
if _cache_invalid SYS_ALL_UNITS$_sys_service_mgr || ! _retrieve_cache SYS_ALL_UNITS$_sys_service_mgr
then
_sys_all_units=( ${${(f)"$(__systemctl list-units --all)"}%% *} )
_store_cache SYS_ALL_UNITS$_sys_service_mgr _sys_all_units
@ -173,9 +173,9 @@ __systemctl()
(( $+functions[_systemctl_really_all_units] )) ||
_systemctl_really_all_units()
{
local -a all_unit_files;
local -a really_all_units;
if _cache_invalid SYS_REALLY_ALL_UNITS$_sys_service_mgr || ! _retrieve_cache SYS_REALLY_ALL_UNITS$_sys_service_mgr;
local -a all_unit_files
local -a really_all_units
if _cache_invalid SYS_REALLY_ALL_UNITS$_sys_service_mgr || ! _retrieve_cache SYS_REALLY_ALL_UNITS$_sys_service_mgr
then
all_unit_files=( ${${(f)"$(__systemctl list-unit-files)"}%% *} )
_systemctl_all_units

View File

@ -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
}
@ -62,8 +62,7 @@
'time:Print time spent in the kernel before reaching userspace'
'blame:Print list of running units ordered by time to init'
'critical-chain:Print a tree of the time critical chain of units'
'plot:Output SVG graphic showing service initialization, or raw time data in
JSON or table format'
'plot:Output SVG graphic showing service initialization, or raw time data in JSON or table format'
'dot:Dump dependency graph (in dot(1) format)'
'dump:Dump server status'
'cat-config:Cat systemd config files'

View File

@ -10,8 +10,8 @@ __systemctl() {
(( $+functions[__systemd-run_get_slices] )) ||
__systemd-run_get_slices () {
__systemctl list-units --all -t slice \
| { while read -r a b; do echo $a; done; };
__systemctl list-units --all -t slice |
{ while read -r a b; do echo $a; done; }
}
(( $+functions[__systemd-run_slices] )) ||