This helps to strip spaces and avoid mangling backslashes:
https://github.com/koalaman/shellcheck/wiki/SC2162
Signed-off-by: Kairui Song kasong@redhat.com --- dracut-module-setup.sh | 14 +++++++------- kdumpctl | 2 +- mkdumprd | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 61ab9803..857b637a 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -106,7 +106,7 @@ kdump_setup_dns() { [ -n "$DNS2" ] && echo "nameserver=$DNS2" >> "$_dnsfile" fi
- while read content; + while read -r content; do _nameserver=$(echo $content | grep ^nameserver) [ -z "$_nameserver" ] && continue @@ -265,7 +265,7 @@ kdump_static_ip() {
/sbin/ip $_ipv6_flag route show | grep -v default |\ grep ".*via.* $_netdev " | grep -v "^[[:space:]]*nexthop" |\ - while read _route; do + while read -r _route; do _target=`echo $_route | cut -d ' ' -f1` _nexthop=`echo $_route | cut -d ' ' -f3` if [ "x" != "x"$_ipv6_flag ]; then @@ -286,7 +286,7 @@ kdump_handle_mulitpath_route() { _ipv6_flag="-6" fi
- while IFS="" read _route; do + while IFS="" read -r _route; do if [[ "$_route" =~ [[:space:]]+nexthop ]]; then _route=${_route##[[:space:]]} # Parse multipath route, using previous _target @@ -464,7 +464,7 @@ find_online_znet_device() { for d in $NETWORK_DEVICES do [ ! -f "$d/online" ] && continue - read ONLINE < $d/online + read -r ONLINE < $d/online if [ $ONLINE -ne 1 ]; then continue fi @@ -472,7 +472,7 @@ find_online_znet_device() { # device is online) if [ -f $d/if_name ] then - read ifname < $d/if_name + read -r ifname < $d/if_name elif [ -d $d/net ] then ifname=$(ls $d/net/) @@ -684,7 +684,7 @@ kdump_install_conf() {
kdump_read_conf > "${initdir}/tmp/$$-kdump.conf"
- while read _opt _val; + while read -r _opt _val; do # remove inline comments after the end of a directive. case "$_opt" in @@ -752,7 +752,7 @@ kdump_get_iscsi_initiator() {
[ -f "$initiator_conf" ] || return 1
- while read _initiator; do + while read -r _initiator; do [ -z "${_initiator%%#*}" ] && continue # Skip comment lines
case $_initiator in diff --git a/kdumpctl b/kdumpctl index 7602c43e..28310946 100755 --- a/kdumpctl +++ b/kdumpctl @@ -704,7 +704,7 @@ load_kdump()
check_ssh_config() { - while read config_opt config_val; do + while read -r config_opt config_val; do case "$config_opt" in sshkey) # remove inline comments after the end of a directive. diff --git a/mkdumprd b/mkdumprd index 2cb82396..af36e003 100644 --- a/mkdumprd +++ b/mkdumprd @@ -387,7 +387,7 @@ if [ -f "$keyfile" ]; then SSH_KEY_LOCATION=$(/usr/bin/readlink -m $keyfile) fi
-while read config_opt config_val; +while read -r config_opt config_val; do # remove inline comments after the end of a directive. case "$config_opt" in