From d66498e7716732a478b40c8136a9fcf4642673fe Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Wed, 16 Feb 2022 13:26:53 -0800 Subject: [PATCH] script/check-config.sh: fix remaining shellcheck warnings ... and add this file to shellcheck target in Makefile. These: In script/check-config.sh line 27: kernelMinor="${kernelVersion#$kernelMajor.}" ^----------^ SC2295 (info): Expansions inside ${..} need to be quoted separately, otherwise they match as patterns. Did you mean: kernelMinor="${kernelVersion#"$kernelMajor".}" In script/check-config.sh line 103: source /etc/os-release 2>/dev/null || /bin/true ^-------------^ SC1091 (info): Not following: /etc/os-release was not specified as input (see shellcheck -x). In script/check-config.sh line 267: NET_CLS_CGROUP $netprio ^------^ SC2206 (warning): Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a. Signed-off-by: Kir Kolyshkin --- Makefile | 2 +- script/check-config.sh | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 6b2b43f2d..bc6b80bef 100644 --- a/Makefile +++ b/Makefile @@ -133,7 +133,7 @@ cfmt: shellcheck: shellcheck tests/integration/*.bats tests/integration/*.sh \ tests/integration/*.bash tests/*.sh \ - script/release_*.sh script/seccomp.sh script/lib.sh + script/* # TODO: add shellcheck for more sh files shfmt: diff --git a/script/check-config.sh b/script/check-config.sh index e82793304..7a700af23 100755 --- a/script/check-config.sh +++ b/script/check-config.sh @@ -24,7 +24,7 @@ fi kernelVersion="$(uname -r)" kernelMajor="${kernelVersion%%.*}" -kernelMinor="${kernelVersion#$kernelMajor.}" +kernelMinor="${kernelVersion#"$kernelMajor".}" kernelMinor="${kernelMinor%%.*}" kernel_lt() { @@ -113,7 +113,9 @@ check_flags() { } check_distro_userns() { - source /etc/os-release 2>/dev/null || /bin/true + [ -r /etc/os-release ] || return 0 + # shellcheck source=/dev/null + . /etc/os-release 2>/dev/null || return 0 if [[ "${ID}" =~ ^(centos|rhel)$ && "${VERSION_ID}" =~ ^7 ]]; then # this is a CentOS7 or RHEL7 system grep -q "user_namespace.enable=1" /proc/cmdline || { @@ -277,7 +279,7 @@ flags=( BLK_CGROUP BLK_DEV_THROTTLING CGROUP_PERF CGROUP_HUGETLB - NET_CLS_CGROUP $netprio + NET_CLS_CGROUP "$netprio" CFS_BANDWIDTH FAIR_GROUP_SCHED RT_GROUP_SCHED IP_NF_TARGET_REDIRECT IP_VS