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