3 # lndir - create shadow link tree
5 # Time stamp <89/11/28 18:56:54 gildea>
6 # By Stephen Gildea <gildea@bbn.com> based on
7 # XConsortium: lndir.sh,v 1.1 88/10/20 17:37:16 jim Exp
9 # Modified slightly for ImageMagick by Bob Friesenhahn, 1999
11 # Used to create a copy of the a directory tree that has links for all
12 # non- directories. If you are building the distribution on more than
13 # one machine, you should use this script.
15 # If your master sources are located in /usr/local/src/X and you would like
16 # your link tree to be in /usr/local/src/new-X, do the following:
18 # % mkdir /usr/local/src/new-X
19 # % cd /usr/local/src/new-X
22 # Note: does not link files beginning with "." Is this a bug or a feature?
24 # Improvements over R3 version:
25 # Allows the fromdir to be relative: usually you want to say "../dist"
26 # The name is relative to the todir, not the current directory.
28 # Bugs in R3 version fixed:
29 # Do "pwd" command *after* "cd $DIRTO".
30 # Don't try to link directories, avoiding error message "<dir> exists".
31 # Barf with Usage message if either DIRFROM *or* DIRTO is not a directory.
33 USAGE="Usage: $0 fromdir [todir]"
35 if [ $# -lt 1 -o $# -gt 2 ]
52 echo "$0: $DIRTO is not a directory"
61 echo "$0: $DIRFROM is not a directory"
68 if [ `(cd $DIRFROM; pwd)` = $pwd ]
70 echo "$pwd: FROM and TO are identical!"
74 for file in `ls $DIRFROM`
76 if [ ! -d $DIRFROM/$file ]
78 test -r $file || ln -s $DIRFROM/$file .
81 test -d $file || mkdir $file && chmod 777 $file
86 *) DIRFROM=../$DIRFROM ;;
88 if [ `(cd $DIRFROM/$file; pwd)` = $pwd ]
90 echo "$pwd: FROM and TO are identical!"