This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Quickly adds world read permissions to files and world read/write permissions | |
# to directories recursively. «-u user[:group]» will additionally chmod files | |
# and directories recursively. | |
function fixperms { | |
typeset -a paths | |
typeset chownUserGroup | |
until ${1+'false'}; do | |
case $1 in | |
-u) | |
if [[ -n $2 ]]; then | |
chownUserGroup=$2 | |
command shift 2 | |
else | |
echo 'Must supply a user:group for the -u option' >&2 | |
return 1 | |
fi | |
;; | |
--) | |
[[ -n $2 ]] && paths+=("${@:2}") | |
command shift "$#" | |
break | |
;; | |
*) [[ -d $1 ]] && paths+=("$1") | |
command shift | |
esac | |
done | |
(( ${#paths[@]} )) || paths+=(.) | |
find -- "${paths[@]}" \ | |
\( \( -type d -exec chmod o+rx -- {} + \) -o \( -type f -exec chmod o+r -- {} + \) \) \ | |
${chownUserGroup:+'-false'} -exec chown "$chownUserGroup" -- {} + | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment