Files
MokoCassiopeia/scripts/validate/tabs.sh
Jonathan Miller 1a667920ab Refactor tabs.sh to use bash for tab detection
Removed copyright notice and unnecessary comments. Updated script to detect tab characters in source files using bash instead of Python.

Signed-off-by: Jonathan Miller <jmiller2979@gmail.com>
2026-01-03 15:16:04 -06:00

29 lines
580 B
Bash

#!/usr/bin/env bash
set -euo pipefail
# Detect TAB characters in source files tracked by Git. Uses careful
# handling of filenames and avoids heredoc pitfalls.
# Limit file globs as appropriate for the repo
files=$(git ls-files '*.php' '*.js' '*.py' || true)
if [ -z "${files}" ]; then
echo "No files to check"
exit 0
fi
bad=0
while IFS= read -r f; do
if grep -n $'\t' -- "$f" >/dev/null 2>&1; then
echo "TAB found in $f"
bad=1
fi
done <<< "${files}"
if [ "${bad}" -ne 0 ]; then
echo "ERROR: Tabs found in repository files" >&2
exit 2
fi
echo "tabs: ok"