aboutsummaryrefslogtreecommitdiff
path: root/symlink-tree
blob: 096582db6eb6426e681539e9f55b1a4ca18281f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/sh
# Create a symlink tree.
#
# Syntax: symlink-tree srcdir "ignore1 ignore2 ..."
#
# where srcdir is the directory to create a symlink tree to,
# and "ignoreN" is a list of files/directories to ignore.

prog=$0
srcdir=$1
ignore="$2"

ignore_additional=". .. CVS"

# If we were invoked with a relative path name, adjust ${prog} to work
# in subdirs.
case ${prog} in
/*) ;;
*) prog=../${prog} ;;
esac

# Set newsrcdir to something subdirectories can use.
case ${srcdir} in
/*) newsrcdir=${srcdir} ;;
*) newsrcdir=../${srcdir} ;;
esac

for f in `ls -a ${srcdir}`; do
  if [ -d ${srcdir}/$f ]; then
    found=
    for i in ${ignore} ${ignore_additional}; do
      if [ "$f" = "$i" ]; then
	found=yes
      fi
    done
    if [ -z "${found}" ]; then
      echo "$f		..working in"
      if [ -d $f ]; then true; else mkdir $f; fi
      (cd $f; ${prog} ${newsrcdir}/$f "${ignore}")
    fi
  else
    echo "$f		..linked"
    rm -f $f
    ln -s ${srcdir}/$f .
  fi
done

exit 0