From 893a013ae9910f9e706a17c66f4025a541788f18 Mon Sep 17 00:00:00 2001 From: Kroese Date: Sun, 14 Jan 2024 01:11:58 +0100 Subject: [PATCH] style: Quote variables (#563) --- .github/workflows/check.yml | 2 +- src/disk.sh | 26 +++++++++++++------------- src/display.sh | 4 ++-- src/install.sh | 2 +- src/network.sh | 18 +++++++++--------- src/print.sh | 2 +- src/proc.sh | 8 ++++---- src/reset.sh | 18 +++++++++--------- src/serial.sh | 10 +++++----- 9 files changed, 45 insertions(+), 45 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index ee48e42..da13975 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -11,4 +11,4 @@ jobs: - name: Run ShellCheck uses: ludeeus/action-shellcheck@master env: - SHELLCHECK_OPTS: -x --source-path=src -e SC2001 -e SC2223 -e SC2034 -e SC2064 -e SC2317 -e SC2153 -e SC2028 + SHELLCHECK_OPTS: -x --source-path=src -e SC2001 -e SC2034 -e SC2064 -e SC2317 -e SC2153 -e SC2028 diff --git a/src/disk.sh b/src/disk.sh index 0493963..17bce7c 100644 --- a/src/disk.sh +++ b/src/disk.sh @@ -3,12 +3,12 @@ set -Eeuo pipefail # Docker environment variables -: ${DISK_IO:='native'} # I/O Mode, can be set to 'native', 'threads' or 'io_turing' -: ${DISK_FMT:='raw'} # Disk file format, 'raw' by default for best performance -: ${DISK_FLAGS:=''} # Specifies the options for use with the qcow2 disk format -: ${DISK_CACHE:='none'} # Caching mode, can be set to 'writeback' for better performance -: ${DISK_DISCARD:='on'} # Controls whether unmap (TRIM) commands are passed to the host. -: ${DISK_ROTATION:='1'} # Rotation rate, set to 1 for SSD storage and increase for HDD +: "${DISK_IO:='native'}" # I/O Mode, can be set to 'native', 'threads' or 'io_turing' +: "${DISK_FMT:='raw'}" # Disk file format, 'raw' by default for best performance +: "${DISK_FLAGS:=''}" # Specifies the options for use with the qcow2 disk format +: "${DISK_CACHE:='none'}" # Caching mode, can be set to 'writeback' for better performance +: "${DISK_DISCARD:='on'}" # Controls whether unmap (TRIM) commands are passed to the host. +: "${DISK_ROTATION:='1'}" # Rotation rate, set to 1 for SSD storage and increase for HDD BOOT="$STORAGE/$BASE.boot.img" SYSTEM="$STORAGE/$BASE.system.img" @@ -472,14 +472,14 @@ fi DISK4_FILE="/storage4/data4" -: ${DISK2_SIZE:=''} -: ${DISK3_SIZE:=''} -: ${DISK4_SIZE:=''} +: "${DISK2_SIZE:=''}" +: "${DISK3_SIZE:=''}" +: "${DISK4_SIZE:=''}" -: ${DEVICE:=''} # Docker variables to passthrough a block device, like /dev/vdc1. -: ${DEVICE2:=''} -: ${DEVICE3:=''} -: ${DEVICE4:=''} +: "${DEVICE:=''}" # Docker variables to passthrough a block device, like /dev/vdc1. +: "${DEVICE2:=''}" +: "${DEVICE3:=''}" +: "${DEVICE4:=''}" if [ -n "$DEVICE" ]; then addDevice "userdata" "$DEVICE" "device" "3" "0xc" || exit $? diff --git a/src/display.sh b/src/display.sh index 0819579..b30424b 100644 --- a/src/display.sh +++ b/src/display.sh @@ -3,8 +3,8 @@ set -Eeuo pipefail # Docker environment variables -: ${GPU:='N'} # GPU passthrough -: ${DISPLAY:='none'} # Display type +: "${GPU:='N'}" # GPU passthrough +: "${DISPLAY:='none'}" # Display type if [[ "$GPU" != [Yy1]* ]] || [[ "$ARCH" != "amd64" ]]; then diff --git a/src/install.sh b/src/install.sh index 52f1fd0..0fa6bcc 100644 --- a/src/install.sh +++ b/src/install.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -Eeuo pipefail -: ${URL:=''} # URL of the PAT file to be downloaded. +: "${URL:=''}" # URL of the PAT file to be downloaded. if [ -f "$STORAGE/dsm.ver" ]; then BASE=$(<"$STORAGE/dsm.ver") diff --git a/src/network.sh b/src/network.sh index dcbda17..05bcc04 100644 --- a/src/network.sh +++ b/src/network.sh @@ -3,17 +3,17 @@ set -Eeuo pipefail # Docker environment variables -: ${DHCP:='N'} -: ${MAC:='02:11:32:AA:BB:CC'} +: "${DHCP:='N'}" +: "${MAC:='02:11:32:AA:BB:CC'}" -: ${VM_NET_DEV:=''} -: ${VM_NET_TAP:='dsm'} -: ${VM_NET_MAC:="$MAC"} -: ${VM_NET_HOST:='VirtualDSM'} +: "${VM_NET_DEV:=''}" +: "${VM_NET_TAP:='dsm'}" +: "${VM_NET_MAC:="$MAC"}" +: "${VM_NET_HOST:='VirtualDSM'}" -: ${DNSMASQ_OPTS:=''} -: ${DNSMASQ:='/usr/sbin/dnsmasq'} -: ${DNSMASQ_CONF_DIR:='/etc/dnsmasq.d'} +: "${DNSMASQ_OPTS:=''}" +: "${DNSMASQ:='/usr/sbin/dnsmasq'}" +: "${DNSMASQ_CONF_DIR:='/etc/dnsmasq.d'}" ADD_ERR="Please add the following setting to your container:" diff --git a/src/print.sh b/src/print.sh index 46d3e54..8dd9df6 100644 --- a/src/print.sh +++ b/src/print.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -Eeuo pipefail -: ${DHCP:='N'} +: "${DHCP:='N'}" info () { printf "%b%s%b" "\E[1;34m❯ \E[1;36m" "$1" "\E[0m\n" >&2; } error () { printf "%b%s%b" "\E[1;31m❯ " "ERROR: $1" "\E[0m\n" >&2; } diff --git a/src/proc.sh b/src/proc.sh index ccece8e..3dc50a6 100644 --- a/src/proc.sh +++ b/src/proc.sh @@ -3,10 +3,10 @@ set -Eeuo pipefail # Docker environment variables -: ${KVM:='Y'} -: ${HOST_CPU:=''} -: ${CPU_MODEL:='host'} -: ${CPU_FEATURES:='+ssse3,+sse4.1,+sse4.2'} +: "${KVM:='Y'}" +: "${HOST_CPU:=''}" +: "${CPU_MODEL:='host'}" +: "${CPU_FEATURES:='+ssse3,+sse4.1,+sse4.2'}" [ "$ARCH" != "amd64" ] && KVM="N" diff --git a/src/reset.sh b/src/reset.sh index 0139845..1a7908e 100644 --- a/src/reset.sh +++ b/src/reset.sh @@ -11,15 +11,15 @@ trap 'error "Status $? while: $BASH_COMMAND (line $LINENO/$BASH_LINENO)"' ERR # Docker environment variables -: ${TZ:=''} # System local timezone -: ${DEBUG:='N'} # Disable debugging mode -: ${COUNTRY:=''} # Country code for mirror -: ${CONSOLE:='N'} # Disable console mode -: ${ALLOCATE:=''} # Preallocate diskspace -: ${ARGUMENTS:=''} # Extra QEMU parameters -: ${CPU_CORES:='1'} # Amount of CPU cores -: ${RAM_SIZE:='1G'} # Maximum RAM amount -: ${DISK_SIZE:='16G'} # Initial data disk size +: "${TZ:=''}" # System local timezone +: "${DEBUG:='N'}" # Disable debugging mode +: "${COUNTRY:=''}" # Country code for mirror +: "${CONSOLE:='N'}" # Disable console mode +: "${ALLOCATE:=''}" # Preallocate diskspace +: "${ARGUMENTS:=''}" # Extra QEMU parameters +: "${CPU_CORES:='1'}" # Amount of CPU cores +: "${RAM_SIZE:='1G'}" # Maximum RAM amount +: "${DISK_SIZE:='16G'}" # Initial data disk size # Helper variables diff --git a/src/serial.sh b/src/serial.sh index 0361089..581f10c 100644 --- a/src/serial.sh +++ b/src/serial.sh @@ -3,11 +3,11 @@ set -Eeuo pipefail # Docker environment variables -: ${HOST_MAC:=''} -: ${HOST_DEBUG:=''} -: ${HOST_SERIAL:=''} -: ${HOST_MODEL:=''} -: ${GUEST_SERIAL:=''} +: "${HOST_MAC:=''}" +: "${HOST_DEBUG:=''}" +: "${HOST_SERIAL:=''}" +: "${HOST_MODEL:=''}" +: "${GUEST_SERIAL:=''}" HOST_ARGS=() HOST_ARGS+=("-cpu=$CPU_CORES")