symlink-tree revision 33965
133965Sjdp#!/bin/sh 233965Sjdp# Create a symlink tree. 333965Sjdp# 433965Sjdp# Syntax: symlink-tree srcdir "ignore1 ignore2 ..." 533965Sjdp# 633965Sjdp# where srcdir is the directory to create a symlink tree to, 733965Sjdp# and "ignoreN" is a list of files/directories to ignore. 833965Sjdp 933965Sjdpprog=$0 1033965Sjdpsrcdir=$1 1133965Sjdpignore="$2" 1233965Sjdp 1333965Sjdpignore_additional=". .. CVS" 1433965Sjdp 1533965Sjdp# If we were invoked with a relative path name, adjust ${prog} to work 1633965Sjdp# in subdirs. 1733965Sjdpcase ${prog} in 1833965Sjdp/*) ;; 1933965Sjdp*) prog=../${prog} ;; 2033965Sjdpesac 2133965Sjdp 2233965Sjdp# Set newsrcdir to something subdirectories can use. 2333965Sjdpcase ${srcdir} in 2433965Sjdp/*) newsrcdir=${srcdir} ;; 2533965Sjdp*) newsrcdir=../${srcdir} ;; 2633965Sjdpesac 2733965Sjdp 2833965Sjdpfor f in `ls -a ${srcdir}`; do 2933965Sjdp if [ -d ${srcdir}/$f ]; then 3033965Sjdp found= 3133965Sjdp for i in ${ignore} ${ignore_additional}; do 3233965Sjdp if [ "$f" = "$i" ]; then 3333965Sjdp found=yes 3433965Sjdp fi 3533965Sjdp done 3633965Sjdp if [ -z "${found}" ]; then 3733965Sjdp if [ -d $f ]; then true; else mkdir $f; fi 3833965Sjdp (cd $f; ${prog} ${newsrcdir}/$f "${ignore}") 3933965Sjdp fi 4033965Sjdp else 4133965Sjdp rm -f $f 4233965Sjdp ln -s ${srcdir}/$f . 4333965Sjdp fi 4433965Sjdpdone 4533965Sjdp 4633965Sjdpexit 0 47