diff previous-work/more_control_helpers/lib/chmod @ 1:d6bef198ae71

add work by Matthias S. Benkmann which is the inspiration for this project.
author Robert McIntyre <rlm@mit.edu>
date Tue, 08 Jan 2013 11:45:01 +0000
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/previous-work/more_control_helpers/lib/chmod	Tue Jan 08 11:45:01 2013 +0000
     1.3 @@ -0,0 +1,45 @@
     1.4 +#!/bin/bash
     1.5 +# Copyright (c) 2004 Matthias S. Benkmann <article AT winterdrache DOT de>
     1.6 +# You may do everything with this code except misrepresent its origin.
     1.7 +# PROVIDED `AS IS' WITH ABSOLUTELY NO WARRANTY OF ANY KIND!
     1.8 +
     1.9 +DAISY_CHAIN=""
    1.10 +
    1.11 +for p in $(type -ap chmod) ; do
    1.12 +  if [ ! $p -ef $0 ]; then DAISY_CHAIN=$p ; break ; fi
    1.13 +done
    1.14 +
    1.15 +if [ ! -n "$DAISY_CHAIN" ]; then
    1.16 +  echo Cannot find real ${0##*/} command 
    1.17 +  exit 1
    1.18 +fi
    1.19 +
    1.20 +if [ $UID == 0 ]; then
    1.21 +  exec $DAISY_CHAIN "$@"
    1.22 +fi
    1.23 +
    1.24 +report=0
    1.25 +doit=1
    1.26 +reportmsg="*** chmod $@"
    1.27 +
    1.28 +set -- "$@" eND_ofLisT
    1.29 +while true ; do
    1.30 +  arg="$1"
    1.31 +  shift 1
    1.32 +  case "_$arg" in
    1.33 +    _eND_ofLisT) break ;;
    1.34 +    _g+s|_u+s) report=1; doit=0  ;;
    1.35 +    _4755) arg=755 ; report=1; doit=1 ;;
    1.36 +    _4555) arg=555 ; report=1; doit=1 ;;
    1.37 +    *) ;;
    1.38 +  esac
    1.39 +  set -- "$@" "$arg"
    1.40 +done
    1.41 +
    1.42 +if [ "$report" = 1 ]; then echo 1>&2 "$reportmsg" ; fi
    1.43 +
    1.44 +if [ "$doit" = 1 ]; then  
    1.45 +  exec $DAISY_CHAIN "$@"
    1.46 +fi
    1.47 +
    1.48 +exit 0