]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
scripts/init.d/cgconfig.in: make it shellcheck complaint
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Fri, 25 Mar 2022 06:06:17 +0000 (11:36 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Tue, 29 Mar 2022 21:11:09 +0000 (15:11 -0600)
Make cgconfig.in shellcheck complaint.  It fixes all the issues reported
by the shellcheck version version 0.7.0.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
scripts/init.d/cgconfig.in

index 83cffe9d0f2c83bc535aba6d0bd0684f83d8a083..527430e042bb8832cb5dc19c6febdc1e3f41ee76 100644 (file)
@@ -38,8 +38,10 @@ lockfile=/run/lock/subsys/$servicename
 SYSLIBFILE=/lib/lsb/init-functions
 OLDSYSLIBFILE=/etc/init.d/functions
 if [[ -x  $SYSLIBFILE ]] ; then
+  # shellcheck disable=SC1090
   source $SYSLIBFILE
 elif  [[ -x $OLDSYSLIBFILE ]] ; then
+  # shellcheck disable=SC1090
   source $OLDSYSLIBFILE
   log_warning_msg() ( warning "$@" ; printf "\n" 1>&2 ; )
   log_failure_msg() ( failure "$@" ; printf "\n" 1>&2 ; )
@@ -53,6 +55,7 @@ fi
 # read the config
 CREATE_DEFAULT=yes
 if [ -e /etc/sysconfig/cgconfig ]; then
+       # shellcheck disable=SC1091
         source /etc/sysconfig/cgconfig
 fi
 
@@ -62,8 +65,9 @@ create_default_groups() {
        defaultcgroup=
 
         if [ -f /etc/cgrules.conf ]; then
-           read user ctrl defaultcgroup <<< \
-                   $(grep -m1 '^\*[[:space:]]\+' /etc/cgrules.conf)
+           # shellcheck disable=SC2034
+           read -r user ctrl defaultcgroup <<< \
+                   "$(grep -m1 '^\*[[:space:]]\+' /etc/cgrules.conf)"
            if [[ ( -n "$defaultcgroup" ) && ( "$defaultcgroup" = "*" ) ]]; then
                 log_warning_msg "/etc/cgrules.conf incorrect"
                 log_warning_msg "Overriding it"
@@ -86,23 +90,23 @@ create_default_groups() {
         # Create the default group, ignore errors when the default group
         # already exists.
         #
-        cgcreate -f 664 -d 775 -g $controllers:$defaultcgroup 2>/dev/null
+        cgcreate -f 664 -d 775 -g "$controllers":"$defaultcgroup" 2>/dev/null
 
         #
         # special rule for cpusets
         #
-        if echo $controllers | grep -q -w cpuset; then
+        if echo "$controllers" | grep -q -w cpuset; then
                 cpus=$(cgget -nv -r cpuset.cpus /)
-                cgset -r cpuset.cpus=$cpus $defaultcgroup
+                cgset -r cpuset.cpus="$cpus $defaultcgroup"
                 mems=$(cgget -nv -r cpuset.mems /)
-                cgset -r cpuset.mems=$mems $defaultcgroup
+                cgset -r cpuset.mems="$mems $defaultcgroup"
         fi
 
         #
         # Classify everything to default cgroup. Ignore errors, some processes
         # may exit after ps is run and before cgclassify moves them.
         #
-        cgclassify -g $controllers:$defaultcgroup $(ps --no-headers -eL o tid) \
+        cgclassify -g "$controllers:$defaultcgroup $(ps --no-headers -eL o tid)" \
                  2>/dev/null || :
 }