fix: double quote to prevent globbing and word splitting (SC2086)

https://www.shellcheck.net/wiki/SC2086
This commit is contained in:
Martin Wimpress 2024-05-09 04:25:06 +01:00 committed by Martin Wimpress
parent 84c71e9cfc
commit e80cd7aeff
2 changed files with 15 additions and 15 deletions

View File

@ -421,7 +421,7 @@ function vm_boot() {
_IFS=$IFS _IFS=$IFS
IFS="," IFS=","
for f in "${ovmfs[@]}"; do for f in "${ovmfs[@]}"; do
set -- $f; set -- "${f}";
if [ -e "${1}" ]; then if [ -e "${1}" ]; then
EFI_CODE="${1}" EFI_CODE="${1}"
EFI_EXTRA_VARS="${2}" EFI_EXTRA_VARS="${2}"
@ -1241,7 +1241,7 @@ function vm_boot() {
echo " - Monitor: (off)" echo " - Monitor: (off)"
elif [ "${MONITOR}" == "telnet" ]; then elif [ "${MONITOR}" == "telnet" ]; then
# Find a free port to expose monitor-telnet to the guest # Find a free port to expose monitor-telnet to the guest
TEMP_PORT="$(get_port ${MONITOR_TELNET_PORT} 9)" TEMP_PORT="$(get_port "${MONITOR_TELNET_PORT}" 9)"
if [ -z "${TEMP_PORT}" ]; then if [ -z "${TEMP_PORT}" ]; then
echo " - Monitor: All Monitor-Telnet ports have been exhausted." echo " - Monitor: All Monitor-Telnet ports have been exhausted."
else else
@ -1280,7 +1280,7 @@ function vm_boot() {
args+=(-serial none) args+=(-serial none)
elif [ "${SERIAL}" == "telnet" ]; then elif [ "${SERIAL}" == "telnet" ]; then
# Find a free port to expose serial-telnet to the guest # Find a free port to expose serial-telnet to the guest
TEMP_PORT="$(get_port ${SERIAL_TELNET_PORT} 9)" TEMP_PORT="$(get_port "${SERIAL_TELNET_PORT}" 9)"
if [ -z "${TEMP_PORT}" ]; then if [ -z "${TEMP_PORT}" ]; then
echo " - Serial: All Serial-Telnet ports have been exhausted." echo " - Serial: All Serial-Telnet ports have been exhausted."
else else

View File

@ -2531,7 +2531,7 @@ function get_truenas-scale() {
local ISO="" local ISO=""
local URL="" local URL=""
local DLINFO="https://www.truenas.com/download-truenas-scale/" local DLINFO="https://www.truenas.com/download-truenas-scale/"
URL=$(web_pipe ${DLINFO} | grep -o "\"https://.*${RELEASE}.*\.iso\"" | cut -d'"' -f 2) URL=$(web_pipe "${DLINFO}" | grep -o "\"https://.*${RELEASE}.*\.iso\"" | cut -d'"' -f 2)
HASH=$(web_pipe "${URL}.sha256" | cut_1) HASH=$(web_pipe "${URL}.sha256" | cut_1)
echo "${URL} ${HASH}" echo "${URL} ${HASH}"
} }
@ -2540,7 +2540,7 @@ function get_truenas-core() {
local ISO="" local ISO=""
local URL="" local URL=""
local DLINFO="https://www.truenas.com/download-truenas-core/" local DLINFO="https://www.truenas.com/download-truenas-core/"
URL=$(web_pipe ${DLINFO} | grep -o "\"https://.*${RELEASE}.*\.iso\"" | cut -d'"' -f 2) URL=$(web_pipe "${DLINFO}" | grep -o "\"https://.*${RELEASE}.*\.iso\"" | cut -d'"' -f 2)
HASH=$(web_pipe "${URL}".sha256 | cut_1) HASH=$(web_pipe "${URL}".sha256 | cut_1)
echo "${URL} ${HASH}" echo "${URL} ${HASH}"
} }
@ -2572,12 +2572,12 @@ function get_ubuntu-server() {
if web_check "${URL}/SHA256SUMS"; then if web_check "${URL}/SHA256SUMS"; then
DATA=$(web_pipe "${URL}/SHA256SUMS" | grep "${NAME}" | grep amd64 | grep iso) DATA=$(web_pipe "${URL}/SHA256SUMS" | grep "${NAME}" | grep amd64 | grep iso)
ISO=$(cut -d'*' -f2 <<<${DATA}) ISO=$(cut -d'*' -f2 <<<"${DATA}")
HASH=$(cut_1 <<<${DATA}) HASH=$(cut_1 <<<"${DATA}")
else else
DATA=$(web_pipe "${URL}/MD5SUMS" | grep "${NAME}" | grep amd64 | grep iso) DATA=$(web_pipe "${URL}/MD5SUMS" | grep "${NAME}" | grep amd64 | grep iso)
ISO=$(cut -d' ' -f3 <<<${DATA}) ISO=$(cut -d' ' -f3 <<<"${DATA}")
HASH=$(cut_1 <<<${DATA}) HASH=$(cut_1 <<<"${DATA}")
fi fi
if [[ "${RELEASE}" == "daily"* ]] || [ "${RELEASE}" == "dvd" ]; then if [[ "${RELEASE}" == "daily"* ]] || [ "${RELEASE}" == "dvd" ]; then
zsync_get "${URL}/${ISO}" "${VM_PATH}" "${OS}-devel.iso" zsync_get "${URL}/${ISO}" "${VM_PATH}" "${OS}-devel.iso"
@ -2618,15 +2618,15 @@ function get_ubuntu() {
fi fi
if web_check "${URL}/SHA256SUMS"; then if web_check "${URL}/SHA256SUMS"; then
DATA=$(web_pipe "${URL}/SHA256SUMS" | grep 'desktop\|dvd\|install' | grep amd64 | grep iso | grep -v "+mac") DATA=$(web_pipe "${URL}/SHA256SUMS" | grep 'desktop\|dvd\|install' | grep amd64 | grep iso | grep -v "+mac")
ISO=$(cut -d'*' -f2 <<<${DATA} | sed '1q;d') ISO=$(cut -d'*' -f2 <<<"${DATA}" | sed '1q;d')
HASH=$(cut_1 <<<${DATA} | sed '1q;d') HASH=$(cut_1 <<<"${DATA}" | sed '1q;d')
else else
DATA=$(web_pipe "${URL}/MD5SUMS" | grep 'desktop\|dvd\|install' | grep amd64 | grep iso | grep -v "+mac") DATA=$(web_pipe "${URL}/MD5SUMS" | grep 'desktop\|dvd\|install' | grep amd64 | grep iso | grep -v "+mac")
ISO=$(cut -d'*' -f2 <<<${DATA}) ISO=$(cut -d'*' -f2 <<<"${DATA}")
HASH=$(cut_1 <<<${DATA}) HASH=$(cut_1 <<<"${DATA}")
fi fi
if [ -z "${ISO}" ] || [ -z "${HASH}" ]; then if [ -z "${ISO}" ] || [ -z "${HASH}" ]; then
echo "$(pretty_name $OS) ${RELEASE} is currently unavailable. Please select other OS/Release combination" echo "$(pretty_name "${OS}") ${RELEASE} is currently unavailable. Please select other OS/Release combination"
exit 1 exit 1
fi fi
if [[ "${RELEASE}" == "daily"* ]] || [ "${RELEASE}" == "dvd" ]; then if [[ "${RELEASE}" == "daily"* ]] || [ "${RELEASE}" == "dvd" ]; then
@ -3539,7 +3539,7 @@ if [ -n "${2}" ]; then
# If the OS has an editions_() function, use it. # If the OS has an editions_() function, use it.
if [[ $(type -t "editions_${OS}") == function ]]; then if [[ $(type -t "editions_${OS}") == function ]]; then
validate_release "releases_${OS}" validate_release "releases_${OS}"
EDITIONS=("$(editions_${OS})") EDITIONS=("$(editions_"${OS}")")
# Default to the first edition if none is specified. # Default to the first edition if none is specified.
EDITION=${EDITIONS[0]} EDITION=${EDITIONS[0]}
if [ -n "${3}" ]; then if [ -n "${3}" ]; then