More experimentation with the dependency logging features of cpp and xsltproc.
[mgear/mgear.git] / experiments / dep-logging / sip
1 #!/bin/bash
2 # Simple include processor as an example of a dependency-logging command.
3 # sip input output depoutput
4 # Follows `include foo' at the beginning of a line.
5
6 exec 3>"$3"
7 exec >"$2"
8
9 function do_read {
10         echo "$1" >&3
11         [ -r "$1" ] || exit 1
12         while IFS='' read line; do
13                 if [[ "$line" == "include "* ]]; then
14                         do_read "${line#include }"
15                 else
16                         echo "$line"
17                 fi
18         done <"$1"
19 }
20
21 do_read "$1"