lint-executable-resources.sh 819 B

1234567891011121314151617181920212223
  1. #!/usr/bin/env bash
  2. set -eo pipefail
  3. script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
  4. cd "$script_path/.."
  5. if [ "$(uname -s)" = "Darwin" ]; then
  6. # MacOS's find does not support '-executable' OR '-perm /mode'.
  7. BAD_FILES=$(find Base/res/ -type f -perm +111)
  8. BAD_FILES+=$(find Tests/ -name WPT -prune -or -perm +111 \! -type d -print | grep -Ev '\.(sh|py)$' || true)
  9. else
  10. BAD_FILES=$(find Base/res/ -type f -executable)
  11. BAD_FILES+=$(find Tests/ -name WPT -prune -or -executable \! -type d -print | grep -Ev '\.(sh|py)$' || true)
  12. fi
  13. if [ -n "${BAD_FILES}" ]
  14. then
  15. echo "These files are marked as executable, but are in directories that do not commonly"
  16. echo "contain executables. Please double-check the permissions of these files:"
  17. echo "${BAD_FILES}" | xargs ls -ld
  18. exit 1
  19. fi