1 |
#! /bin/sh |
2 |
|
3 |
make_targets_file() |
4 |
{ |
5 |
# local file line line_nr error targets_file files |
6 |
targets_file="$1" |
7 |
shift |
8 |
files="$@" |
9 |
printf "" > "$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 '\[' >/dev/null ; do |
17 |
if echo $line | grep '\[.*\]' >/dev/null; then |
18 |
printf "%s %s " "$file" "$line_nr" >> "$targets_file" |
19 |
echo $line | sed -e 's,^[^\[]*\[,,' -e 's,\].*$,,' \ |
20 |
>> "$targets_file" |
21 |
else |
22 |
echo "In \`$file\' line $line_nr: target brackets inbalance" >&2 |
23 |
error=1 |
24 |
fi |
25 |
line=`echo $line | sed -e 's,^[^]]*\],,'` |
26 |
done |
27 |
if [ $error -eq 0 ] && echo $line | grep '\]' >/dev/null ; then |
28 |
echo "In \`$file\' line $line_nr: target brackets inbalance" >&2 |
29 |
error=1 |
30 |
fi |
31 |
line_nr=`echo "$line_nr + 1" | bc` |
32 |
done |
33 |
) < $file |
34 |
done |
35 |
} |
36 |
|
37 |
|
38 |
make_targets_file "$@" |