a "replacement" for awk and sed
[p5sagit/p5-mst-13.2.git] / makedir.SH
1 case $CONFIG in
2 '')
3     if test ! -f config.sh; then
4         ln ../config.sh . || \
5         ln ../../config.sh . || \
6         ln ../../../config.sh . || \
7         (echo "Can't find config.sh."; exit 1)
8     fi
9     . config.sh
10     ;;
11 esac
12 case "$0" in
13 */*) cd `expr X$0 : 'X\(.*\)/'` ;;
14 esac
15 echo "Extracting makedir (with variable substitutions)"
16 $spitshell >makedir <<!GROK!THIS!
17 $startsh
18 # $Header: makedir.SH,v 1.0 87/12/18 13:05:32 root Exp $
19
20 # $Log: makedir.SH,v $
21 # Revision 1.0  87/12/18  13:05:32  root
22 # Initial revision
23
24 # Revision 4.3.1.1  85/05/10  11:35:14  lwall
25 # Branch for patches.
26
27 # Revision 4.3  85/05/01  11:42:31  lwall
28 # Baseline for release with 4.3bsd.
29
30
31 export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh \$0; kill \$\$)
32
33 case \$# in
34   0)
35     $echo "makedir pathname filenameflag"
36     exit 1
37     ;;
38 esac
39
40 : guarantee one slash before 1st component
41 case \$1 in
42   /*) ;;
43   *)  set ./\$1 \$2 ;;
44 esac
45
46 : strip last component if it is to be a filename
47 case X\$2 in
48   X1) set \`$echo \$1 | $sed 's:\(.*\)/[^/]*\$:\1:'\` ;;
49   *)  set \$1 ;;
50 esac
51
52 : return reasonable status if nothing to be created
53 if $test -d "\$1" ; then
54     exit 0
55 fi
56
57 list=''
58 while true ; do
59     case \$1 in
60     */*)
61         list="\$1 \$list"
62         set \`echo \$1 | $sed 's:\(.*\)/:\1 :'\`
63         ;;
64     *)
65         break
66         ;;
67     esac
68 done
69
70 set \$list
71
72 for dir do
73     $mkdir \$dir >/dev/null 2>&1
74 done
75 !GROK!THIS!
76 $eunicefix makedir
77 chmod 755 makedir