fix: resolve shellcheck SC2002 and SC2207
https://www.shellcheck.net/wiki/SC2002 https://www.shellcheck.net/wiki/SC2207
This commit is contained in:
parent
16adb86372
commit
013413ee8c
38
quickemu
38
quickemu
|
@ -1469,28 +1469,30 @@ function viewer_param_check() {
|
||||||
|
|
||||||
function parse_ports_from_file {
|
function parse_ports_from_file {
|
||||||
local FILE="${VMDIR}/${VMNAME}.ports"
|
local FILE="${VMDIR}/${VMNAME}.ports"
|
||||||
|
local host_name=""
|
||||||
|
local port_name=""
|
||||||
|
local port_number=""
|
||||||
|
|
||||||
|
# Loop over each line in the file
|
||||||
|
while IFS= read -r CONF || [ -n "${CONF}" ]; do
|
||||||
|
echo "Processing line: ${CONF}"
|
||||||
# parse ports
|
# parse ports
|
||||||
# shellcheck disable=SC2207
|
port_name=$(echo "${CONF}" | cut -d',' -f 1)
|
||||||
local port_name=( $(cat "${FILE}" | cut -d',' -f 1) )
|
port_number=$(echo "${CONF}" | cut -d',' -f 2)
|
||||||
# shellcheck disable=SC2207
|
host_name=$(echo "${CONF}" | awk 'FS="," {print $3,"."}')
|
||||||
local port_number=( $(cat "${FILE}" | cut -d',' -f 2) )
|
|
||||||
# shellcheck disable=SC2207
|
|
||||||
local host_name=( $(cat "${FILE}" | gawk 'FS="," {print $3,"."}') )
|
|
||||||
|
|
||||||
for ((i=0; i<${#port_name[@]}; i++)); do
|
if [ "${port_name}" == "ssh" ]; then
|
||||||
if [ "${port_name[$i]}" == "ssh" ]; then
|
SSH_PORT="${port_number}"
|
||||||
SSH_PORT="${port_number[$i]}"
|
elif [ "${port_name}" == "spice" ]; then
|
||||||
elif [ "${port_name[$i]}" == "spice" ]; then
|
SPICE_PORT="${port_number}"
|
||||||
SPICE_PORT="${port_number[$i]}"
|
elif [ "${port_name}" == "monitor-telnet" ]; then
|
||||||
elif [ "${port_name[$i]}" == "monitor-telnet" ]; then
|
MONITOR_TELNET_PORT="${port_number}"
|
||||||
MONITOR_TELNET_PORT="${port_number[$i]}"
|
MONITOR_TELNET_HOST="${host_name}"
|
||||||
MONITOR_TELNET_HOST="${host_name[$i]}"
|
elif [ "${port_name}" == "serial-telnet" ]; then
|
||||||
elif [ "${port_name[$i]}" == "serial-telnet" ]; then
|
SERIAL_TELNET_PORT="${port_number}"
|
||||||
SERIAL_TELNET_PORT="${port_number[$i]}"
|
SERIAL_TELNET_HOST="${host_name}"
|
||||||
SERIAL_TELNET_HOST="${host_name[$i]}"
|
|
||||||
fi
|
fi
|
||||||
done
|
done < "${FILE}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_numeric {
|
function is_numeric {
|
||||||
|
|
Loading…
Reference in New Issue