ambevar-dotfiles/.scripts/sanitize

24 lines
458 B
Bash
Executable File

#!/bin/sh
if [ $# -eq 0 ] || [ "$1" = "-h" ]; then
cat <<EOF
Usage: ${0##*/} [FOLDER]
Set file/directory owner and permissions according to current umask for current
used.
EOF
exit
fi
WORKDIR="$PWD"
if [ $# -eq 1 ]; then
WORKDIR="$1"
fi
FMASK=$(umask -S | sed 's/x//g')
DMASK=$(umask -S)
find "$WORKDIR" -exec chown -R ${UID}:${GID} {} \;
find "$WORKDIR" -type d -exec chmod ${DMASK} {} \;
find "$WORKDIR" -type f -exec chmod ${FMASK} {} \;