Skip to content

Commit 198ded6

Browse files
committed
shellcheck: SC2086: Double quote to prevent globbing and word splitting.
Signed-off-by: Akihiro Suda <[email protected]>
1 parent c6730b4 commit 198ded6

File tree

3 files changed

+16
-19
lines changed

3 files changed

+16
-19
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,8 @@ jobs:
3232
run: |
3333
sudo apt-get update
3434
sudo apt-get install -y shellcheck
35-
- name: Run shellcheck (ignore SC2086)
36-
# TODO: do not ignore SC2086
37-
# SC2086: "Double quote to prevent globbing and word splitting."
38-
# https://github.com/koalaman/shellcheck/wiki/SC2086
39-
run: find . -name '*.sh' | xargs shellcheck -e SC2086
35+
- name: Run shellcheck
36+
run: find . -name '*.sh' | xargs shellcheck
4037

4138
shfmt:
4239
runs-on: ubuntu-20.04

pkg/cidata/cidata.TEMPLATE.d/boot/05-persistent-data-volume.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,29 @@ if [ "$(awk '$2 == "/" {print $3}' /proc/mounts)" == "tmpfs" ]; then
2323
# Looking for a disk that is not mounted or partitioned
2424
# shellcheck disable=SC2013
2525
for PART in $(awk '/^\/dev\// {gsub("/dev/", ""); print $1}' /proc/mounts); do
26-
if [ "${DISK}" == "${PART}" ] || [ -e /sys/block/${DISK}/${PART} ]; then
26+
if [ "${DISK}" == "${PART}" ] || [ -e /sys/block/"${DISK}"/"${PART}" ]; then
2727
IN_USE=true
2828
break
2929
fi
3030
done
3131
if [ "${IN_USE}" == "false" ]; then
32-
echo 'type=83' | sfdisk --label dos /dev/${DISK}
33-
PART=$(lsblk --list /dev/${DISK} --noheadings --output name,type | awk '$2 == "part" {print $1}')
34-
mkfs.ext4 -L data-volume /dev/${PART}
32+
echo 'type=83' | sfdisk --label dos /dev/"${DISK}"
33+
PART=$(lsblk --list /dev/"${DISK}" --noheadings --output name,type | awk '$2 == "part" {print $1}')
34+
mkfs.ext4 -L data-volume /dev/"${PART}"
3535
mount -t ext4 /dev/disk/by-label/data-volume /mnt/data
3636
for DIR in ${DATADIRS}; do
37-
DEST="/mnt/data$(dirname ${DIR})"
38-
mkdir -p ${DIR} ${DEST}
39-
mv ${DIR} ${DEST}
37+
DEST="/mnt/data$(dirname "${DIR}")"
38+
mkdir -p "${DIR}" "${DEST}"
39+
mv "${DIR}" "${DEST}"
4040
done
4141
break
4242
fi
4343
done
4444
fi
4545
for DIR in ${DATADIRS}; do
46-
if [ -d /mnt/data${DIR} ]; then
47-
[ -e ${DIR} ] && rm -rf ${DIR}
48-
ln -s /mnt/data${DIR} ${DIR}
46+
if [ -d /mnt/data"${DIR}" ]; then
47+
[ -e "${DIR}" ] && rm -rf "${DIR}"
48+
ln -s /mnt/data"${DIR}" "${DIR}"
4949
fi
5050
done
5151
fi

pkg/cidata/cidata.TEMPLATE.d/boot/25-guestagent-base.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -eux
55
# NOTE: Busybox sh does not support `for ((i=0;i<$N;i++))` form
66
for f in $(seq 0 $((LIMA_CIDATA_MOUNTS - 1))); do
77
mountpointvar="LIMA_CIDATA_MOUNTS_${f}_MOUNTPOINT"
8-
mountpoint="$(eval echo \$$mountpointvar)"
8+
mountpoint="$(eval echo \$"$mountpointvar")"
99
mkdir -p "${mountpoint}"
1010
chown "${LIMA_CIDATA_USER}" "${mountpoint}"
1111
done
@@ -16,9 +16,9 @@ install -m 755 "${LIMA_CIDATA_MNT}"/lima-guestagent /usr/local/bin/lima-guestage
1616
# Launch the guestagent service
1717
if [ -f /etc/alpine-release ]; then
1818
# Create directory for the lima-guestagent socket (normally done by systemd)
19-
mkdir -p /run/user/${LIMA_CIDATA_UID}
20-
chown "${LIMA_CIDATA_USER}" /run/user/${LIMA_CIDATA_UID}
21-
chmod 700 /run/user/${LIMA_CIDATA_UID}
19+
mkdir -p /run/user/"${LIMA_CIDATA_UID}"
20+
chown "${LIMA_CIDATA_USER}" /run/user/"${LIMA_CIDATA_UID}"
21+
chmod 700 /run/user/"${LIMA_CIDATA_UID}"
2222
# Install the openrc lima-guestagent service script
2323
cat >/etc/init.d/lima-guestagent <<'EOF'
2424
#!/sbin/openrc-run

0 commit comments

Comments
 (0)