view previous-work/more_control_helpers/lib/chmod @ 36:d66d34065dd9 tip

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