sanitize 510 B

123456789101112131415161718192021222324252627
  1. #!/bin/sh
  2. usage () {
  3. cat <<EOF>&2
  4. Usage: ${0##*/} FOLDERS
  5. Set file/directory owner and permissions according to current umask for current
  6. user.
  7. EOF
  8. }
  9. [ $# -eq 0 ] && usage && exit 1
  10. [ "$1" = "-h" ] && usage && exit
  11. [ "$1" = "--" ] && shift
  12. FMASK=$(umask -S | sed 's/x//g')
  13. DMASK=$(umask -S)
  14. [ -z "$UID" ] && UID=$(id -u)
  15. [ -z "$GID" ] && GID=$(id -g)
  16. for i ; do
  17. find "$i" -exec chown -R "$UID:$GID" {} \;
  18. find "$i" -type d -exec chmod "$DMASK" {} \;
  19. find "$i" -type f -exec chmod "$FMASK" {} \;
  20. done