Skip to content
Snippets Groups Projects
Unverified Commit e94775f1 authored by Matthias Schiffer's avatar Matthias Schiffer
Browse files

lint: sh: add checking for initscripts

Detect initscripts by their shebang line. SC2034 is ignored additionally
for these scripts, to avoid needing to override it for setting START,
USE_PROCD, ... in every single script.
parent c2d14538
No related branches found
No related tags found
No related merge requests found
...@@ -6,6 +6,10 @@ is_scriptfile() { ...@@ -6,6 +6,10 @@ is_scriptfile() {
echo "$1" | grep -q '\.sh$' || head -n1 "$1" | grep -qE '^#!(.*\<bash|/bin/sh)$' echo "$1" | grep -q '\.sh$' || head -n1 "$1" | grep -qE '^#!(.*\<bash|/bin/sh)$'
} }
is_initscript() {
head -n1 "$1" | grep -qxF '#!/bin/sh /etc/rc.common'
}
find contrib -type f | while read -r file; do find contrib -type f | while read -r file; do
is_scriptfile "$file" || continue is_scriptfile "$file" || continue
...@@ -14,10 +18,13 @@ find contrib -type f | while read -r file; do ...@@ -14,10 +18,13 @@ find contrib -type f | while read -r file; do
done done
find package -type f | while read -r file; do find package -type f | while read -r file; do
is_scriptfile "$file" || continue if is_scriptfile "$file"; then
echo "Checking $file" echo "Checking $file"
shellcheck -f gcc -x -s sh -e SC2039,SC3043,SC3037,SC3057 "$file" shellcheck -f gcc -x -s sh -e SC2039,SC3043,SC3037,SC3057 "$file"
elif is_initscript "$file"; then
echo "Checking $file (initscript)"
shellcheck -f gcc -x -s sh -e SC2034,SC2039,SC3043,SC3037,SC3057 "$file"
fi
done done
find scripts -type f | while read -r file; do find scripts -type f | while read -r file; do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment