view previous-work/more_control_helpers/lib/mkdir @ 14:ac1ca422bd54

saving progress.
author Robert McIntyre <rlm@mit.edu>
date Wed, 09 Jan 2013 10:59:43 +0000
parents d6bef198ae71
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