File: symlink-tree

package info (click to toggle)
dejagnu 1.3-10
  • links: PTS
  • area: main
  • in suites: slink
  • size: 6,992 kB
  • ctags: 2,864
  • sloc: ansic: 41,277; exp: 9,037; sh: 2,765; makefile: 2,439; lisp: 1,403; tcl: 1,242
file content (46 lines) | stat: -rwxr-xr-x 923 bytes parent folder | download | duplicates (7)
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
#!/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
      if [ -d $f ]; then true; else mkdir $f; fi
      (cd $f; ${prog} ${newsrcdir}/$f "${ignore}")
    fi
  else
    rm -f $f
    ln -s ${srcdir}/$f .
  fi
done

exit 0