view previous-work/more_control_helpers/lib/mkdir @ 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 source
1 #!/bin/bash
2 # Copyright (c) 2000 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 watchdir=/usr/share/locale
8 DAISY_CHAIN=""
10 for p in $(type -ap mkdir) ; do
11 if [ ! $p -ef $0 ]; then DAISY_CHAIN=$p ; break ; fi
12 done
14 if [ ! -n "$DAISY_CHAIN" ]; then
15 echo Cannot find real ${0##*/} command
16 exit 1
17 fi
19 if [ $UID == 0 ]; then
20 exec $DAISY_CHAIN "$@"
21 fi
23 cmdline="$@"
25 dirs=""
26 for((i=$#; $i>0;))
27 do
28 a="$1"
29 shift 1; i=$(($i-1))
30 case "$a" in
31 $watchdir/*) dirs="$dirs ""`expr $a : "$watchdir/\(.*\)"`"
32 set -- "$@" "$a"
33 ;;
34 *) set -- "$@" "$a" ;;
35 esac
36 done
38 $DAISY_CHAIN "$@" || exit $?
40 test z"$dirs" != z &&
41 echo 1>&2 '***' mkdir "$cmdline"
42 for dir in $dirs ; do
43 cumuldir=""
44 for d in `echo $dirs | sed 's#/# #g' -` ; do
45 cumuldir=$cumuldir$d/
46 chgrp install $watchdir/$cumuldir
47 test -k $watchdir/$cumuldir || chmod g+w,o+t $watchdir/$cumuldir
48 done
49 done
50 exit 0