diff --git a/scripts/lint-sh.sh b/scripts/lint-sh.sh index e6cf284986c805eb2efda67da6260a96a0fba1a6..1cb16c71e8340587c28fca24bfa71e9972914d91 100755 --- a/scripts/lint-sh.sh +++ b/scripts/lint-sh.sh @@ -6,6 +6,10 @@ is_scriptfile() { 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 is_scriptfile "$file" || continue @@ -14,10 +18,13 @@ find contrib -type f | while read -r file; do done find package -type f | while read -r file; do - is_scriptfile "$file" || continue - - echo "Checking $file" - shellcheck -f gcc -x -s sh -e SC2039,SC3043,SC3037,SC3057 "$file" + if is_scriptfile "$file"; then + echo "Checking $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 find scripts -type f | while read -r file; do