check_file_permissions.sh 536 B

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