mkdirhier.sh now accepts -q, which makes it be quiet
[ghc-hetmet.git] / utils / mkdirhier / mkdirhier.sh
1 #!/bin/sh
2
3 #
4 # create a hierarchy of directories
5 #
6 # Based on Noah Friedman's mkinstalldirs..
7 #
8
9 quiet=no
10 errs=0
11
12 if [ "$1" = "-q" ]
13 then
14     shift
15     quiet=yes
16 fi
17
18 for f in $*; do
19     parts=`echo ":$f" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
20     path="";
21     for p in $parts; do
22         path="$path$p"
23         case "$path" in
24           -* ) path=./$path ;;
25         esac
26
27         if test ! -d "$path"; then
28            if [ "$quiet" = "no" ]
29            then
30                echo "mkdir $path" 1>&2
31            fi
32
33            mkdir "$path" || lasterr=$?
34            
35            if test ! -d "$path"; then
36               errs=$lasterr
37            fi 
38         fi
39         path="$path/";
40     done;
41 done
42
43 exit $errs
44
45 # end of story