From 01e769bc2ed45f39367aa607b23b6f04b785ee64 Mon Sep 17 00:00:00 2001 From: Eisuke Kawashima Date: Mon, 14 Jul 2025 16:08:09 +0900 Subject: [PATCH] fix(SC2162): add `-r` to `read` --- shell-completion/bash/busctl | 12 ++++++------ shell-completion/bash/homectl | 2 +- shell-completion/bash/hostnamectl | 2 +- shell-completion/bash/importctl | 8 ++++++-- shell-completion/bash/journalctl | 2 +- shell-completion/bash/kernel-install | 2 +- shell-completion/bash/loginctl | 2 +- shell-completion/bash/machinectl | 2 +- shell-completion/bash/portablectl | 2 +- shell-completion/bash/run0 | 2 +- shell-completion/bash/systemctl.in | 2 +- shell-completion/bash/systemd-analyze | 2 +- shell-completion/bash/systemd-cgls | 2 +- shell-completion/bash/systemd-cgtop | 2 +- shell-completion/bash/systemd-nspawn | 8 ++++---- shell-completion/bash/timedatectl | 2 +- shell-completion/zsh/_bootctl | 2 +- shell-completion/zsh/_busctl | 8 ++++---- shell-completion/zsh/_kernel-install | 2 +- shell-completion/zsh/_sd_machines | 2 +- 20 files changed, 36 insertions(+), 32 deletions(-) diff --git a/shell-completion/bash/busctl b/shell-completion/bash/busctl index 4527b5bdbe8..e0960397255 100644 --- a/shell-completion/bash/busctl +++ b/shell-completion/bash/busctl @@ -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() { diff --git a/shell-completion/bash/homectl b/shell-completion/bash/homectl index 6d7e23ef718..8976245fda0 100644 --- a/shell-completion/bash/homectl +++ b/shell-completion/bash/homectl @@ -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() { diff --git a/shell-completion/bash/hostnamectl b/shell-completion/bash/hostnamectl index 8d1922eb2e0..0baffeed9c1 100644 --- a/shell-completion/bash/hostnamectl +++ b/shell-completion/bash/hostnamectl @@ -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() { diff --git a/shell-completion/bash/importctl b/shell-completion/bash/importctl index 0eed6defd8d..779e66cbf2a 100644 --- a/shell-completion/bash/importctl +++ b/shell-completion/bash/importctl @@ -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 } diff --git a/shell-completion/bash/journalctl b/shell-completion/bash/journalctl index 2c4ffffe07e..31e8e0d935b 100644 --- a/shell-completion/bash/journalctl +++ b/shell-completion/bash/journalctl @@ -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 } diff --git a/shell-completion/bash/kernel-install b/shell-completion/bash/kernel-install index a7714ad1880..9d20b2fd055 100644 --- a/shell-completion/bash/kernel-install +++ b/shell-completion/bash/kernel-install @@ -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 diff --git a/shell-completion/bash/loginctl b/shell-completion/bash/loginctl index 9085d2dd5f5..f0e1196e615 100644 --- a/shell-completion/bash/loginctl +++ b/shell-completion/bash/loginctl @@ -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 } diff --git a/shell-completion/bash/machinectl b/shell-completion/bash/machinectl index 7e837361141..eda11f55904 100644 --- a/shell-completion/bash/machinectl +++ b/shell-completion/bash/machinectl @@ -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 } diff --git a/shell-completion/bash/portablectl b/shell-completion/bash/portablectl index 87c4a5ee4f7..824510bbcae 100644 --- a/shell-completion/bash/portablectl +++ b/shell-completion/bash/portablectl @@ -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 } diff --git a/shell-completion/bash/run0 b/shell-completion/bash/run0 index 80300cd9ab1..fe2efedd309 100644 --- a/shell-completion/bash/run0 +++ b/shell-completion/bash/run0 @@ -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 } diff --git a/shell-completion/bash/systemctl.in b/shell-completion/bash/systemctl.in index 7bc5ddb8772..1004ac60431 100644 --- a/shell-completion/bash/systemctl.in +++ b/shell-completion/bash/systemctl.in @@ -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") } diff --git a/shell-completion/bash/systemd-analyze b/shell-completion/bash/systemd-analyze index d9861848848..24478dd3bf8 100644 --- a/shell-completion/bash/systemd-analyze +++ b/shell-completion/bash/systemd-analyze @@ -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 } diff --git a/shell-completion/bash/systemd-cgls b/shell-completion/bash/systemd-cgls index 9c0393d045e..2ec843f0464 100644 --- a/shell-completion/bash/systemd-cgls +++ b/shell-completion/bash/systemd-cgls @@ -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 } diff --git a/shell-completion/bash/systemd-cgtop b/shell-completion/bash/systemd-cgtop index 41381bd24c3..a444b650643 100644 --- a/shell-completion/bash/systemd-cgtop +++ b/shell-completion/bash/systemd-cgtop @@ -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 } diff --git a/shell-completion/bash/systemd-nspawn b/shell-completion/bash/systemd-nspawn index 2a826204014..597c1b681d2 100644 --- a/shell-completion/bash/systemd-nspawn +++ b/shell-completion/bash/systemd-nspawn @@ -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(){ diff --git a/shell-completion/bash/timedatectl b/shell-completion/bash/timedatectl index 14628822f61..2690907f9ee 100644 --- a/shell-completion/bash/timedatectl +++ b/shell-completion/bash/timedatectl @@ -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 } diff --git a/shell-completion/zsh/_bootctl b/shell-completion/zsh/_bootctl index 79f9f45fa01..3f7f4b5c86c 100644 --- a/shell-completion/zsh/_bootctl +++ b/shell-completion/zsh/_bootctl @@ -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 diff --git a/shell-completion/zsh/_busctl b/shell-completion/zsh/_busctl index 296afd1e24d..6fea1bf1b19 100644 --- a/shell-completion/zsh/_busctl +++ b/shell-completion/zsh/_busctl @@ -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 diff --git a/shell-completion/zsh/_kernel-install b/shell-completion/zsh/_kernel-install index 0e786e36f09..b581281c26e 100644 --- a/shell-completion/zsh/_kernel-install +++ b/shell-completion/zsh/_kernel-install @@ -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]* ) diff --git a/shell-completion/zsh/_sd_machines b/shell-completion/zsh/_sd_machines index a1c7de1b2c7..7e859f5fd32 100644 --- a/shell-completion/zsh/_sd_machines +++ b/shell-completion/zsh/_sd_machines @@ -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 }