PMbwmon bandwidth monitor: can specify which interfaces to watch, also supporting...
[hband-tools.git] / user-tools / uchmod
blob4e0360435d473be832acd02fae4d2209d6d60cbf
1 #!/bin/bash
3 declare -a chmod_opt
4 chmod_opt=()
5 maxdepth="-maxdepth 0"
7 help()
9 echo "Usage: $0 [--verbose | --changes | --recursive] <files and folders>" >&2
10 exit ${1:-1}
13 while [ -n "$1" ]
15 case "$1" in
16 -v|--verbose|-c|--changes)
17 chmod_opt+=("$1")
19 -R|--recursive)
20 maxdepth=
22 -h|--help)
23 help 0
25 --) shift
26 break
28 -*) echo "Unknown option: $1" >&2
29 exit 1
31 *) break
33 esac
34 shift
35 done
37 if [ -z "$1" ]
38 then
39 help 1
42 fmod=`umask -S | tr -d x`
43 dmod=`umask -S`
44 find "$@" $maxdepth \( -type f -exec chmod "${chmod_opt[@]}" "$fmod" {} \; \) -o \( -type d -exec chmod "${chmod_opt[@]}" "$dmod" {} \; \)
47 true <<EOF
49 =pod
51 =head1 NAME
53 uchmod - chmod files according to umask
55 =head1 SYNOPSIS
57 uchmod [-v] [-R] [B<path>-1] [B<path>-2] ... [B<path>-n]
59 =head1 DESCRIPTION
61 Change mode bits of files and directories according to umask(1) settings using chmod(1).
62 Use it when file modes were messed up, B<uchmod> change them like mode of newly created files.
64 =cut
66 EOF