1 |
frodo |
149 |
#! /bin/sh |
2 |
frodo |
2 |
|
3 |
frodo |
149 |
make_targets_file() |
4 |
frodo |
2 |
{ |
5 |
frodo |
149 |
# local file line line_nr error targets_file files |
6 |
frodo |
2 |
targets_file="$1" |
7 |
|
|
shift |
8 |
|
|
files="$@" |
9 |
|
|
echo -n "" > "$targets_file" |
10 |
|
|
|
11 |
|
|
for file in $files; do |
12 |
|
|
( |
13 |
|
|
line_nr=1 |
14 |
|
|
while read line; do |
15 |
|
|
error=0 |
16 |
|
|
while [ $error -eq 0 ] && echo $line | grep -q '\[' ; do |
17 |
frodo |
149 |
if echo $line | grep -q '\[.*\]'; then |
18 |
|
|
# The use of ! is not portable. |
19 |
frodo |
2 |
echo -n "$file $line_nr " >> "$targets_file" |
20 |
|
|
echo $line | sed -e 's,^[^\[]*\[,,' -e 's,\].*$,,' \ |
21 |
|
|
>> "$targets_file" |
22 |
frodo |
149 |
else |
23 |
|
|
echo "In \`$file\' line $line_nr: target brackets inbalance" >&2 |
24 |
|
|
error=1 |
25 |
frodo |
2 |
fi |
26 |
|
|
line=`echo $line | sed -e 's,^[^]]*\],,'` |
27 |
|
|
done |
28 |
|
|
if [ $error -eq 0 ] && echo $line | grep -q '\]' ; then |
29 |
|
|
echo "In \`$file\' line $line_nr: target brackets inbalance" >&2 |
30 |
|
|
error=1 |
31 |
|
|
fi |
32 |
|
|
line_nr=$[$line_nr+1] |
33 |
|
|
done |
34 |
|
|
) < $file |
35 |
|
|
done |
36 |
|
|
} |
37 |
|
|
|
38 |
|
|
|
39 |
|
|
make_targets_file "$@" |