| 1 |
|
| 2 |
|
| 3 |
shopt -s extglob |
| 4 |
|
| 5 |
files=$@ |
| 6 |
|
| 7 |
for file in ${files[@]}; do |
| 8 |
output= |
| 9 |
template= |
| 10 |
|
| 11 |
if [ "$file" != "${file/%setup.xml/}" ]; then |
| 12 |
template=1 |
| 13 |
fi |
| 14 |
|
| 15 |
while IFS= read -r line; do |
| 16 |
compare= |
| 17 |
|
| 18 |
|
| 19 |
if [ -n "$output" ]; then |
| 20 |
output=${output}$'\n' |
| 21 |
fi |
| 22 |
|
| 23 |
if [ "$template" == 1 ]; then |
| 24 |
|
| 25 |
if [ "$line" != "${line/<entry id=/}" ]; then |
| 26 |
string=${line##*string=\"} |
| 27 |
string=${string%%\"*} |
| 28 |
line=${line/%\/>/>$string<\/entry>} |
| 29 |
fi |
| 30 |
else |
| 31 |
|
| 32 |
if [ "$line" != "${line/<entry id=/}" ]; then |
| 33 |
compare=${line##*([[:space:]])} |
| 34 |
compare=${compare/%[[:space:]]string=*/} |
| 35 |
elif [ "$line" != "${line/<property name=/}" ]; then |
| 36 |
compare=${line##*([[:space:]])} |
| 37 |
compare=${compare/%>*/} |
| 38 |
fi |
| 39 |
|
| 40 |
|
| 41 |
if [ -n "$compare" ]; then |
| 42 |
match=`grep -m 1 "$compare" "$file"` |
| 43 |
|
| 44 |
if [ -n "$match" ]; then |
| 45 |
line="$match" |
| 46 |
fi |
| 47 |
fi |
| 48 |
fi |
| 49 |
|
| 50 |
output=${output}${line} |
| 51 |
done < "setup.xml" |
| 52 |
|
| 53 |
echo "$output" > "$file" |
| 54 |
done |