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 |
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 |
if echo $line | grep -q '\[.*\]'; then |
18 |
# The use of ! is not portable. |
19 |
echo -n "$file $line_nr " >> "$targets_file" |
20 |
echo $line | sed -e 's,^[^\[]*\[,,' -e 's,\].*$,,' \ |
21 |
>> "$targets_file" |
22 |
else |
23 |
echo "In \`$file\' line $line_nr: target brackets inbalance" >&2 |
24 |
error=1 |
25 |
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 "$@" |