1
0
mirror of https://github.com/systemd/systemd.git synced 2025-10-25 03:33:38 +03:00

fix(SC2162): add -r to read

This commit is contained in:
Eisuke Kawashima
2025-07-14 16:08:09 +09:00
parent cb2e0dc4f5
commit 01e769bc2e
20 changed files with 36 additions and 32 deletions

View File

@@ -27,7 +27,7 @@ __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; } |
{ 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

@@ -29,7 +29,7 @@ __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; } |
{ while read -r a b; do echo " $a"; done; } |
sort -u
}

View File

@@ -38,7 +38,7 @@ _kernel_install() {
2)
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]*)
fi

View File

@@ -33,7 +33,7 @@ __get_all_seats () { loginctl --no-legend list-seats | { while read -r a b
__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; } |
{ while read -r a b; do echo " $a"; done; } |
sort -u
}

View File

@@ -27,7 +27,7 @@ __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; } |
{ while read -r a b; do echo " $a"; done; } |
sort -u
}

View File

@@ -27,7 +27,7 @@ __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; } |
{ while read -r a b; do echo " $a"; done; } |
sort -u
}

View File

@@ -27,7 +27,7 @@ __get_slice_units () { __systemctl list-units --all -t slice |
__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; } |
{ while read -r a b; do echo " $a"; done; } |
sort -u
}

View File

@@ -120,7 +120,7 @@ __get_all_unit_files() { __systemctl $1 list-unit-files "$2*" | while read -r a
__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")
}

View File

@@ -29,7 +29,7 @@ __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; } |
{ while read -r a b; do echo " $a"; done; } |
sort -u
}

View File

@@ -27,7 +27,7 @@ __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; } |
{ while read -r a b; do echo " $a"; done; } |
sort -u
}

View File

@@ -27,7 +27,7 @@ __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; } |
{ while read -r a b; do echo " $a"; done; } |
sort -u
}

View File

@@ -26,24 +26,24 @@ __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 | { 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 | { 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; } |
{ 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 echo " ${a%%=*}"; done; }
}
__get_interfaces(){

View File

@@ -29,7 +29,7 @@ __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; } |
{ while read -r a b; do echo " $a"; done; } |
sort -u
}

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

@@ -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,7 +4,7 @@
(( $+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; } |
{ while read -r a b; do echo "$a"; done; } |
sort -u
}