Mercurial > pkg
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/previous-work/more_control_helpers/lib/mkdir Tue Jan 08 11:45:01 2013 +0000 1.3 @@ -0,0 +1,50 @@ 1.4 +#!/bin/bash 1.5 +# Copyright (c) 2000 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 +watchdir=/usr/share/locale 1.10 + 1.11 +DAISY_CHAIN="" 1.12 + 1.13 +for p in $(type -ap mkdir) ; do 1.14 + if [ ! $p -ef $0 ]; then DAISY_CHAIN=$p ; break ; fi 1.15 +done 1.16 + 1.17 +if [ ! -n "$DAISY_CHAIN" ]; then 1.18 + echo Cannot find real ${0##*/} command 1.19 + exit 1 1.20 +fi 1.21 + 1.22 +if [ $UID == 0 ]; then 1.23 + exec $DAISY_CHAIN "$@" 1.24 +fi 1.25 + 1.26 +cmdline="$@" 1.27 + 1.28 +dirs="" 1.29 +for((i=$#; $i>0;)) 1.30 +do 1.31 + a="$1" 1.32 + shift 1; i=$(($i-1)) 1.33 + case "$a" in 1.34 + $watchdir/*) dirs="$dirs ""`expr $a : "$watchdir/\(.*\)"`" 1.35 + set -- "$@" "$a" 1.36 + ;; 1.37 + *) set -- "$@" "$a" ;; 1.38 + esac 1.39 +done 1.40 + 1.41 +$DAISY_CHAIN "$@" || exit $? 1.42 + 1.43 +test z"$dirs" != z && 1.44 +echo 1>&2 '***' mkdir "$cmdline" 1.45 +for dir in $dirs ; do 1.46 + cumuldir="" 1.47 + for d in `echo $dirs | sed 's#/# #g' -` ; do 1.48 + cumuldir=$cumuldir$d/ 1.49 + chgrp install $watchdir/$cumuldir 1.50 + test -k $watchdir/$cumuldir || chmod g+w,o+t $watchdir/$cumuldir 1.51 + done 1.52 +done 1.53 +exit 0