Files
MokoCassiopeia/scripts/validate/paths.sh
Jonathan Miller 70e3951377 Refactor paths.sh to improve readability and logic
Signed-off-by: Jonathan Miller <jmiller2979@gmail.com>
2026-01-03 15:16:21 -06:00

27 lines
635 B
Bash

#!/usr/bin/env bash
set -euo pipefail
# Detect Windows-style path literals (backslashes) in repository files.
# Uses git ls-files -z and searches file contents for a literal backslash.
hits=()
while IFS= read -r -d '' f; do
# Skip common binary files by mime-type
if file --brief --mime-type "$f" | grep -qE '^(application|audio|image|video)/'; then
continue
fi
if grep -F $'\\' -- "$f" >/dev/null 2>&1; then
hits+=("$f")
fi
done < <(git ls-files -z)
if [ "${#hits[@]}" -gt 0 ]; then
echo "ERROR: windows_path_literal_detected"
for h in "${hits[@]}"; do
echo " - ${h}"
done
exit 2
fi
echo "paths: ok"