Mercurial > pkg
annotate previous-work/more_control_helpers/lib/chmod @ 22:43cfd1a2c523
create program to save acls.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Thu, 10 Jan 2013 07:36:04 +0000 |
parents | d6bef198ae71 |
children |
rev | line source |
---|---|
rlm@1 | 1 #!/bin/bash |
rlm@1 | 2 # Copyright (c) 2004 Matthias S. Benkmann <article AT winterdrache DOT de> |
rlm@1 | 3 # You may do everything with this code except misrepresent its origin. |
rlm@1 | 4 # PROVIDED `AS IS' WITH ABSOLUTELY NO WARRANTY OF ANY KIND! |
rlm@1 | 5 |
rlm@1 | 6 DAISY_CHAIN="" |
rlm@1 | 7 |
rlm@1 | 8 for p in $(type -ap chmod) ; do |
rlm@1 | 9 if [ ! $p -ef $0 ]; then DAISY_CHAIN=$p ; break ; fi |
rlm@1 | 10 done |
rlm@1 | 11 |
rlm@1 | 12 if [ ! -n "$DAISY_CHAIN" ]; then |
rlm@1 | 13 echo Cannot find real ${0##*/} command |
rlm@1 | 14 exit 1 |
rlm@1 | 15 fi |
rlm@1 | 16 |
rlm@1 | 17 if [ $UID == 0 ]; then |
rlm@1 | 18 exec $DAISY_CHAIN "$@" |
rlm@1 | 19 fi |
rlm@1 | 20 |
rlm@1 | 21 report=0 |
rlm@1 | 22 doit=1 |
rlm@1 | 23 reportmsg="*** chmod $@" |
rlm@1 | 24 |
rlm@1 | 25 set -- "$@" eND_ofLisT |
rlm@1 | 26 while true ; do |
rlm@1 | 27 arg="$1" |
rlm@1 | 28 shift 1 |
rlm@1 | 29 case "_$arg" in |
rlm@1 | 30 _eND_ofLisT) break ;; |
rlm@1 | 31 _g+s|_u+s) report=1; doit=0 ;; |
rlm@1 | 32 _4755) arg=755 ; report=1; doit=1 ;; |
rlm@1 | 33 _4555) arg=555 ; report=1; doit=1 ;; |
rlm@1 | 34 *) ;; |
rlm@1 | 35 esac |
rlm@1 | 36 set -- "$@" "$arg" |
rlm@1 | 37 done |
rlm@1 | 38 |
rlm@1 | 39 if [ "$report" = 1 ]; then echo 1>&2 "$reportmsg" ; fi |
rlm@1 | 40 |
rlm@1 | 41 if [ "$doit" = 1 ]; then |
rlm@1 | 42 exec $DAISY_CHAIN "$@" |
rlm@1 | 43 fi |
rlm@1 | 44 |
rlm@1 | 45 exit 0 |