check_file_permissions.sh 557 B

12345678910111213141516171819202122232425262728
  1. #!/bin/sh
  2. set -eu
  3. files_with_wrong_permissions=$(
  4. git ls-files --stage . \
  5. ':!*.sh' \
  6. ':!php-cs-fixer' \
  7. ':!dev-tools/*.php' \
  8. | grep -E "^100755 " \
  9. | sort -fh
  10. )
  11. if [ "$files_with_wrong_permissions" ]
  12. then
  13. printf '\033[97;41mWrong permissions detected:\033[0m\n'
  14. echo "${files_with_wrong_permissions}"
  15. exit 3
  16. fi
  17. if [ -x "php-cs-fixer" ]
  18. then
  19. echo '"php-cs-fixer" is executable'
  20. else
  21. echo '"php-cs-fixer" not is executable'
  22. exit 4
  23. fi
  24. printf '\033[0;32mNo wrong permissions detected.\033[0m\n'