muimaster.library: it is possible to set NULL as entries. Make the code robust to...
[AROS.git] / scripts / makelinks
blobe65751fd5549560c7ec04e2357cf70428a1cde42
1 #!/bin/sh
2 # $0 from to filter
4 scriptdir="`dirname $0`"
6 from="$1"
7 to="$2"
8 if [ -z "$3" ]; then
9 tfilter="*"
10 else
11 tfilter="$3"
14 filter="`gawk 'BEGIN { \
15 str=ARGV[1]; \
16 gsub (/\\./, "\\\\.", str); \
17 gsub(/\\*/,".*",str); \
18 print str; \
19 }' $tfilter`"
21 echo -n "Creating links from $from/ to $to/ "
23 noglob=1
24 echo "$tfilter"
25 unset noglob
27 for direntry in $from/* ; do
28 entry="`basename $direntry`"
29 if [ -d $direntry ]; then
30 if [ "$entry" != "CVS" ]; then
31 if [ ! -d "$to/$entry" ]; then
32 mkdir "$to/$entry"
34 $0 "$direntry" "$to/$entry" "$tfilter"
36 else
37 if echo "$entry" | egrep -q -e "$filter"; then
38 rp="`$scriptdir/relpath $to $from`"
39 #echo "Link $from/$entry to $to/$entry"
40 #echo "Link $rp/$entry to $entry"
41 ( cd $to ; rm -f $entry ; ln -s $rp/$entry $entry )
44 done