From Brad Lucier <lucier@math.purdue.edu>:
[binutils.git] / symlink-tree
blob096582db6eb6426e681539e9f55b1a4ca18281f6
1 #!/bin/sh
2 # Create a symlink tree.
4 # Syntax: symlink-tree srcdir "ignore1 ignore2 ..."
6 # where srcdir is the directory to create a symlink tree to,
7 # and "ignoreN" is a list of files/directories to ignore.
9 prog=$0
10 srcdir=$1
11 ignore="$2"
13 ignore_additional=". .. CVS"
15 # If we were invoked with a relative path name, adjust ${prog} to work
16 # in subdirs.
17 case ${prog} in
18 /*) ;;
19 *) prog=../${prog} ;;
20 esac
22 # Set newsrcdir to something subdirectories can use.
23 case ${srcdir} in
24 /*) newsrcdir=${srcdir} ;;
25 *) newsrcdir=../${srcdir} ;;
26 esac
28 for f in `ls -a ${srcdir}`; do
29 if [ -d ${srcdir}/$f ]; then
30 found=
31 for i in ${ignore} ${ignore_additional}; do
32 if [ "$f" = "$i" ]; then
33 found=yes
35 done
36 if [ -z "${found}" ]; then
37 echo "$f ..working in"
38 if [ -d $f ]; then true; else mkdir $f; fi
39 (cd $f; ${prog} ${newsrcdir}/$f "${ignore}")
41 else
42 echo "$f ..linked"
43 rm -f $f
44 ln -s ${srcdir}/$f .
46 done
48 exit 0