2014-10-11 12:51:23 +04:00
|
|
|
#!/bin/bash
|
|
|
|
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
2023-01-25 17:14:03 +04:00
|
|
|
source "$(dirname -- "$0")/lib/ulib/auto" || exit 1
|
2014-10-11 12:51:23 +04:00
|
|
|
|
|
|
|
function display_help() {
|
|
|
|
uecho "$scriptname: forcer le mode d'une liste de fichiers
|
|
|
|
|
|
|
|
USAGE
|
|
|
|
$scriptname [options] [dirs|files....]
|
|
|
|
|
|
|
|
Le mode forcé pour les répertoires est rwxr-xr-x
|
|
|
|
Le mode forcé pour les fichiers est rw-r--r--
|
|
|
|
|
|
|
|
OPTIONS
|
|
|
|
-x, --executable
|
|
|
|
Forcer le mode rwX-r-Xr-X pour les fichiers"
|
|
|
|
}
|
|
|
|
|
|
|
|
executable=
|
|
|
|
parse_opts "${PRETTYOPTS[@]}" \
|
|
|
|
--help '$exit_with display_help' \
|
|
|
|
-x,--executable executable=1 \
|
|
|
|
@ args -- "$@" && set -- "${args[@]}" || die "$args"
|
|
|
|
|
|
|
|
[ $# -gt 0 ] || set -- .
|
|
|
|
|
|
|
|
dmode=755
|
|
|
|
if [ -n "$executable" ]; then
|
|
|
|
fmode=u=rwX,g=rX,o=rX
|
|
|
|
else
|
|
|
|
fmode=644
|
|
|
|
fi
|
|
|
|
|
|
|
|
r=0
|
|
|
|
for i in "$@"; do
|
|
|
|
if [ -d "$i" ]; then
|
|
|
|
etitle "$i"
|
|
|
|
estep "correction répertoires"
|
|
|
|
find "$i" -type d -print -exec chmod "$dmode" {} \; || r=$?
|
|
|
|
estep "correction fichiers"
|
|
|
|
find "$i" -type f -print -exec chmod "$fmode" {} \; || r=$?
|
|
|
|
eend
|
|
|
|
elif [ -f "$i" ]; then
|
|
|
|
estep "$i"
|
|
|
|
chmod "$fmode" "$i" || r=$?
|
|
|
|
else
|
|
|
|
eerror "$i: fichier introuvable"
|
|
|
|
r=1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
exit $r
|