Add colors
[infodrom.org/service.infodrom.org] / bin / wmldepend.sh
1 #!/bin/sh
2
3 INCPATH=.
4 FILES=''
5
6 expandfile() {
7         for i in $INCPATH
8         do
9                 if [ -f $i/$1 ] 
10                 then
11                         echo $i/$1
12                         exit 0
13                 fi
14         done
15         echo "Error: Include file \`$1' does not exist" > /dev/stderr
16 #       echo "Fehler: Includedatei $1 existiert nicht" > /dev/stderr
17         exit 1
18 }
19
20 findincludes() {
21         for i in $*
22         do
23                 for j in `sed -n 's/^#[Ii][Nn][Cc][Ll][Uu][Dd][Ee] *[<"]\([^>"]*\).*/\1/p' $i` \
24                          `sed -n 's/^#[Rr][Ee][Aa][Dd] *[<"]\([^>"]*\).*/\1/p' $i`
25                 do
26                         echo ' \'
27                         foo=`expandfile $j`
28                         echo -n ' '$foo
29                         findincludes $foo
30                 done
31         done
32 }
33
34 # Argument parsing
35 #
36 while [ "x$1" != "x" ]
37 do
38         case "$1" in
39                 -I*)
40                         INCPATH=$INCPATH' '${1##-I}
41                         #INCPATH=$INCPATH' '$(1)
42                         ;;
43                 *)
44                         FILES=$FILES' '$1
45                         ;;
46         esac
47         shift
48 done
49
50 export INCPATH
51 export FILES
52
53 for i in $FILES
54 do
55         echo -n `echo $i | sed 's/.wml/.html/'`: $i
56         findincludes $i
57         echo
58 done