#!/bin/sh
# SPDX-License-Identifier: LGPL-2.1+
+export LC_ALL=C.UTF-8
+export LANGUAGE=en
+
# Allow environment variables to override config
: ${CONFIG:=/proc/config.gz}
: ${MODNAME:=configs}
-CAT="cat"
+GREP="grep"
if [ -t 1 ]; then
SETCOLOR_SUCCESS="printf \\033[1;32m"
fi
is_set() {
- $CAT $CONFIG | grep "$1=[y|m]" > /dev/null
+ $GREP -wm1 "^${1}=[y|m]" "${CONFIG}" > /dev/null
return $?
}
if [ ! -f /proc/modules ]; then
return
fi
- lsmod | grep $1 > /dev/null
+ lsmod | grep -wm1 "^${1}" > /dev/null
if [ $? -eq 0 ]; then
echo -n ", loaded"
else
fi
if gunzip -tq < $CONFIG 2>/dev/null; then
- CAT="zcat"
+ GREP="zgrep"
fi
-KVER_MAJOR=$($CAT $CONFIG | grep '^# Linux.*Kernel Configuration' | \
- sed -r 's/.* ([0-9])\.[0-9]{1,2}\.[0-9]{1,3}.*/\1/')
+KVER_MAJOR="$($GREP -m1 '^# Linux.*Kernel Configuration' "${CONFIG}" | \
+ sed -r 's/.* ([0-9])\.[0-9]{1,2}\.[0-9]{1,3}.*/\1/')"
if [ "$KVER_MAJOR" = "2" ]; then
-KVER_MINOR=$($CAT $CONFIG | grep '^# Linux.*Kernel Configuration' | \
- sed -r 's/.* 2.6.([0-9]{2}).*/\1/')
+ KVER_MINOR="$($GREP -m1 '^# Linux.*Kernel Configuration' "${CONFIG}" | \
+ sed -r 's/.* 2.6.([0-9]{2}).*/\1/')"
else
-KVER_MINOR=$($CAT $CONFIG | grep '^# Linux.*Kernel Configuration' | \
- sed -r 's/.* [0-9]\.([0-9]{1,3})\.[0-9]{1,3}.*/\1/')
+ KVER_MINOR="$($GREP -m1 '^# Linux.*Kernel Configuration' "${CONFIG}" | \
+ sed -r 's/.* [0-9]\.([0-9]{1,3})\.[0-9]{1,3}.*/\1/')"
fi
if [ -z "${KVER_MAJOR}" ]; then
done
if [ "${CGROUP_V2_MNTS}" != "/sys/fs/cgroup" ]; then
- CGROUP_SYSTEMD_MNTPT=$(echo "$CGROUP_V1_MNTS" | grep "/systemd")
+ CGROUP_SYSTEMD_MNTPT=$(echo "$CGROUP_V1_MNTS" | grep -F "/systemd")
if [ -z "$CGROUP_SYSTEMD_MNTPT" ]; then
echo -n "Cgroup v1 systemd controller: "
$SETCOLOR_FAILURE && echo -n "missing" && $SETCOLOR_NORMAL
echo
fi
- CGROUP_FREEZER_MNTPT=$(echo "$CGROUP_V1_MNTS" | grep "/freezer")
+ CGROUP_FREEZER_MNTPT=$(echo "$CGROUP_V1_MNTS" | grep -F "/freezer")
if [ -z "$CGROUP_FREEZER_MNTPT" ]; then
echo -n "Cgroup v1 freezer controller: "
$SETCOLOR_FAILURE && echo -n "missing" && $SETCOLOR_NORMAL