#!/usr/bin/env bash # SUM Parts - syntax-check every script in this directory # # Cheap guard: a shell script with a syntax error fails at the first line it # reaches, which for an unattended weekend run means losing the weekend. set -uo pipefail cd "$(dirname "${BASH_SOURCE[0]}")" fail=0 echo "=== bash ===" for f in *.sh; do printf ' %-26s' "$f" if bash -n "$f" 2>/dev/null; then echo "OK"; else echo "SYNTAX ERROR"; fail=1; fi done echo echo "=== python ===" for f in *.py; do printf ' %-26s' "$f" if python3 -c "import ast,sys; ast.parse(open(sys.argv[1],encoding='utf-8').read())" "$f" 2>/dev/null then echo "OK"; else echo "SYNTAX ERROR"; fail=1; fi done echo echo "=== CRLF check (breaks bash on Linux) ===" if grep -rlU $'\r' ./*.sh ./*.py 2>/dev/null; then echo " ^ these have CRLF line endings and will fail with: bash: \$'\\r': command not found" fail=1 else echo " clean" fi echo [ "$fail" -eq 0 ] && echo "ALL OK" || echo "PROBLEMS FOUND" exit "$fail"