612aa99aed27952ef7b3b7e724f004be1ca1a878
[platform/upstream/bash.git] / support / mklinks
1
2 # Yet another script which requires an already built Bash.
3 #
4 # This makes links in the current directory to the directory specified as
5 # the first argument.
6 #
7
8 topdir=$1
9
10 if [ ! "$topdir" ]; then
11   echo "No directory specified.  Read the script $0."
12   exit 1
13 fi
14
15 function clone_files ()
16 {
17   local dir=$1;
18   local files;
19
20   files=$(cd $dir; echo *);
21
22   if [ ! "$files" ]; then
23     return 0;
24   fi
25
26   for filename in $files; do
27     if [ -d $dir/$filename ]; then
28       # If the file to clone is this directory, then skip it.
29       if [ $(cd $dir/$filename; pwd) = $(pwd) ]; then
30         continue;
31       fi
32       mkdir $filename;
33       (cd $filename; clone_files ../$dir/$filename)
34     else
35       ln -s $dir/$filename .;
36     fi
37   done
38   rm -f \#* *~ .*~ *.bak .*.bak  *.tmp .*.tmp *.o core a.out;
39 }
40
41 clone_files $topdir