BSD 4_3_Net_2 development
[unix-history] / usr / src / contrib / isode / others / quipu / uips / pod / cpr
CommitLineData
11492ebf
C
1#! /bin/sh
2
3# cp-r
4#
5# Implements recursive copy for machines which do not have the -R option on cp
6#
7# Andrew.Findlay@brunel.ac.uk
8#
9# Derived from:
10#
11# lndir - create shadow link tree
12#
13# Time stamp <89/11/28 18:56:54 gildea>
14# By Stephen Gildea <gildea@bbn.com> based on
15# XConsortium: lndir.sh,v 1.1 88/10/20 17:37:16 jim Exp
16
17
18USAGE="Usage: $0 fromdir [todir]"
19
20if [ $# -lt 1 -o $# -gt 2 ]
21then
22 echo "$USAGE"
23 exit 1
24fi
25
26DIRFROM=$1
27
28if [ $# -eq 2 ];
29then
30 DIRTO=$2
31else
32 DIRTO=.
33fi
34
35if [ ! -d $DIRTO ]
36then
37 echo "$0: $DIRTO is not a directory"
38 echo "$USAGE"
39 exit 2
40fi
41
42case "$DIRFROM" in
43 /*) ;;
44 *) DIRFROM=`pwd`/$DIRFROM ;;
45esac
46
47cd $DIRTO
48
49if [ ! -d $DIRFROM ]
50then
51 echo "$0: $DIRFROM is not a directory"
52 echo "$USAGE"
53 exit 2
54fi
55
56pwd=`pwd`
57
58if [ `(cd $DIRFROM; pwd)` = $pwd ]
59then
60 echo "$pwd: FROM and TO are identical!"
61 exit 1
62fi
63
64for file in `ls -a $DIRFROM`
65do
66 if [ ! -d $DIRFROM/$file ]
67 then
68 #ln -s $DIRFROM/$file .
69 cp $DIRFROM/$file .
70 else
71 if [ \( $file != RCS \) \
72 -a \( $file != . \) \
73 -a \( $file != .. \) ]
74 then
75 #echo $file:
76 mkdir $file
77 (cd $file
78 pwd=`pwd`
79 case "$DIRFROM" in
80 /*) ;;
81 *) DIRFROM=../$DIRFROM ;;
82 esac
83 if [ `(cd $DIRFROM/$file; pwd)` = $pwd ]
84 then
85 echo "$pwd: FROM and TO are identical!"
86 exit 1
87 fi
88 $0 $DIRFROM/$file
89 )
90 fi
91 fi
92done