1 |
frodo |
2 |
#!/bin/sh |
2 |
|
|
|
3 |
|
|
function make_targets_file |
4 |
|
|
{ |
5 |
|
|
local file line line_nr error targets_file files |
6 |
|
|
|
7 |
|
|
targets_file="$1" |
8 |
|
|
shift |
9 |
|
|
files="$@" |
10 |
|
|
echo -n "" > "$targets_file" |
11 |
|
|
|
12 |
|
|
for file in $files; do |
13 |
|
|
( |
14 |
|
|
line_nr=1 |
15 |
|
|
while read line; do |
16 |
|
|
error=0 |
17 |
|
|
while [ $error -eq 0 ] && echo $line | grep -q '\[' ; do |
18 |
|
|
if ! echo $line | grep -q '\[.*\]'; then |
19 |
|
|
echo "In \`$file\' line $line_nr: target brackets inbalance" >&2 |
20 |
|
|
error=1 |
21 |
|
|
else |
22 |
|
|
echo -n "$file $line_nr " >> "$targets_file" |
23 |
|
|
echo $line | sed -e 's,^[^\[]*\[,,' -e 's,\].*$,,' \ |
24 |
|
|
>> "$targets_file" |
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 "$@" |