bash scripts: always use "read -r"
This helps to strip spaces and avoid mangling backslashes: https://github.com/koalaman/shellcheck/wiki/SC2162 Signed-off-by: Kairui Song <kasong@redhat.com> Acked-by: Philipp Rudo <prudo@redhat.com>
This commit is contained in:
parent
fdfad3102e
commit
a416930706
@ -106,7 +106,7 @@ kdump_setup_dns() {
|
|||||||
[ -n "$DNS2" ] && echo "nameserver=$DNS2" >> "$_dnsfile"
|
[ -n "$DNS2" ] && echo "nameserver=$DNS2" >> "$_dnsfile"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while read content;
|
while read -r content;
|
||||||
do
|
do
|
||||||
_nameserver=$(echo $content | grep ^nameserver)
|
_nameserver=$(echo $content | grep ^nameserver)
|
||||||
[ -z "$_nameserver" ] && continue
|
[ -z "$_nameserver" ] && continue
|
||||||
@ -265,7 +265,7 @@ kdump_static_ip() {
|
|||||||
|
|
||||||
/sbin/ip $_ipv6_flag route show | grep -v default |\
|
/sbin/ip $_ipv6_flag route show | grep -v default |\
|
||||||
grep ".*via.* $_netdev " | grep -v "^[[:space:]]*nexthop" |\
|
grep ".*via.* $_netdev " | grep -v "^[[:space:]]*nexthop" |\
|
||||||
while read _route; do
|
while read -r _route; do
|
||||||
_target=`echo $_route | cut -d ' ' -f1`
|
_target=`echo $_route | cut -d ' ' -f1`
|
||||||
_nexthop=`echo $_route | cut -d ' ' -f3`
|
_nexthop=`echo $_route | cut -d ' ' -f3`
|
||||||
if [ "x" != "x"$_ipv6_flag ]; then
|
if [ "x" != "x"$_ipv6_flag ]; then
|
||||||
@ -286,7 +286,7 @@ kdump_handle_mulitpath_route() {
|
|||||||
_ipv6_flag="-6"
|
_ipv6_flag="-6"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while IFS="" read _route; do
|
while IFS="" read -r _route; do
|
||||||
if [[ "$_route" =~ [[:space:]]+nexthop ]]; then
|
if [[ "$_route" =~ [[:space:]]+nexthop ]]; then
|
||||||
_route=${_route##[[:space:]]}
|
_route=${_route##[[:space:]]}
|
||||||
# Parse multipath route, using previous _target
|
# Parse multipath route, using previous _target
|
||||||
@ -465,7 +465,7 @@ find_online_znet_device() {
|
|||||||
for d in $NETWORK_DEVICES
|
for d in $NETWORK_DEVICES
|
||||||
do
|
do
|
||||||
[ ! -f "$d/online" ] && continue
|
[ ! -f "$d/online" ] && continue
|
||||||
read ONLINE < $d/online
|
read -r ONLINE < $d/online
|
||||||
if [ $ONLINE -ne 1 ]; then
|
if [ $ONLINE -ne 1 ]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
@ -473,7 +473,7 @@ find_online_znet_device() {
|
|||||||
# device is online)
|
# device is online)
|
||||||
if [ -f $d/if_name ]
|
if [ -f $d/if_name ]
|
||||||
then
|
then
|
||||||
read ifname < $d/if_name
|
read -r ifname < $d/if_name
|
||||||
elif [ -d $d/net ]
|
elif [ -d $d/net ]
|
||||||
then
|
then
|
||||||
ifname=$(ls $d/net/)
|
ifname=$(ls $d/net/)
|
||||||
@ -685,7 +685,7 @@ kdump_install_conf() {
|
|||||||
|
|
||||||
kdump_read_conf > "${initdir}/tmp/$$-kdump.conf"
|
kdump_read_conf > "${initdir}/tmp/$$-kdump.conf"
|
||||||
|
|
||||||
while read _opt _val;
|
while read -r _opt _val;
|
||||||
do
|
do
|
||||||
# remove inline comments after the end of a directive.
|
# remove inline comments after the end of a directive.
|
||||||
case "$_opt" in
|
case "$_opt" in
|
||||||
@ -753,7 +753,7 @@ kdump_get_iscsi_initiator() {
|
|||||||
|
|
||||||
[ -f "$initiator_conf" ] || return 1
|
[ -f "$initiator_conf" ] || return 1
|
||||||
|
|
||||||
while read _initiator; do
|
while read -r _initiator; do
|
||||||
[ -z "${_initiator%%#*}" ] && continue # Skip comment lines
|
[ -z "${_initiator%%#*}" ] && continue # Skip comment lines
|
||||||
|
|
||||||
case $_initiator in
|
case $_initiator in
|
||||||
|
2
kdumpctl
2
kdumpctl
@ -704,7 +704,7 @@ load_kdump()
|
|||||||
|
|
||||||
check_ssh_config()
|
check_ssh_config()
|
||||||
{
|
{
|
||||||
while read config_opt config_val; do
|
while read -r config_opt config_val; do
|
||||||
case "$config_opt" in
|
case "$config_opt" in
|
||||||
sshkey)
|
sshkey)
|
||||||
# remove inline comments after the end of a directive.
|
# remove inline comments after the end of a directive.
|
||||||
|
2
mkdumprd
2
mkdumprd
@ -390,7 +390,7 @@ if [ -f "$keyfile" ]; then
|
|||||||
SSH_KEY_LOCATION=$(/usr/bin/readlink -m $keyfile)
|
SSH_KEY_LOCATION=$(/usr/bin/readlink -m $keyfile)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while read config_opt config_val;
|
while read -r config_opt config_val;
|
||||||
do
|
do
|
||||||
# remove inline comments after the end of a directive.
|
# remove inline comments after the end of a directive.
|
||||||
case "$config_opt" in
|
case "$config_opt" in
|
||||||
|
Loading…
Reference in New Issue
Block a user