]>
Commit | Line | Data |
---|---|---|
6599da04 JM |
1 | #!/bin/sh |
2 | # Create a symlink tree. | |
3 | # | |
4 | # Syntax: symlink-tree srcdir "ignore1 ignore2 ..." | |
5 | # | |
6 | # where srcdir is the directory to create a symlink tree to, | |
7 | # and "ignoreN" is a list of files/directories to ignore. | |
8 | ||
9 | prog=$0 | |
10 | srcdir=$1 | |
11 | ignore="$2" | |
12 | ||
3abaac67 PE |
13 | if test $# -lt 1; then |
14 | echo "symlink-tree error: Usage: symlink-tree srcdir \"ignore1 ignore2 ...\"" | |
15 | exit 1 | |
16 | fi | |
17 | ||
6599da04 JM |
18 | ignore_additional=". .. CVS" |
19 | ||
20 | # If we were invoked with a relative path name, adjust ${prog} to work | |
21 | # in subdirs. | |
22 | case ${prog} in | |
fc26516b | 23 | /* | [A-Za-z]:[\\/]*) ;; |
6599da04 JM |
24 | *) prog=../${prog} ;; |
25 | esac | |
26 | ||
27 | # Set newsrcdir to something subdirectories can use. | |
28 | case ${srcdir} in | |
fc26516b | 29 | /* | [A-Za-z]:[\\/]*) newsrcdir=${srcdir} ;; |
6599da04 JM |
30 | *) newsrcdir=../${srcdir} ;; |
31 | esac | |
32 | ||
33 | for f in `ls -a ${srcdir}`; do | |
34 | if [ -d ${srcdir}/$f ]; then | |
35 | found= | |
36 | for i in ${ignore} ${ignore_additional}; do | |
37 | if [ "$f" = "$i" ]; then | |
38 | found=yes | |
39 | fi | |
40 | done | |
41 | if [ -z "${found}" ]; then | |
42 | echo "$f ..working in" | |
43 | if [ -d $f ]; then true; else mkdir $f; fi | |
44 | (cd $f; ${prog} ${newsrcdir}/$f "${ignore}") | |
45 | fi | |
46 | else | |
47 | echo "$f ..linked" | |
48 | rm -f $f | |
49 | ln -s ${srcdir}/$f . | |
50 | fi | |
51 | done | |
52 | ||
53 | exit 0 |